Skip to content

Commit

Permalink
Merge pull request #99 from ComradeProgrammer/materialized_referesh
Browse files Browse the repository at this point in the history
fix: refreshing materialized view
  • Loading branch information
medyagh authored Dec 4, 2023
2 parents 815242b + 9583f03 commit 1b887ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ testdata/docker-test/testout.json
testdata/docker-test/testout.html
./gopogh
cmd/gopogh-server/gopogh-server
.vscode
.vscode/
11 changes: 9 additions & 2 deletions pkg/db/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,15 @@ func (m *Postgres) createMaterializedView(env string, viewName string) error {
WHERE Result != 'skip' AND EnvName = '%s' AND TestTime >= NOW() - INTERVAL '90 days'
`, viewName, env)

_, err := m.db.Exec(createView)
return err
if _, err := m.db.Exec(createView); err != nil {
return err
}
// refresh the materialzed view
refreshView := fmt.Sprintf("REFRESH MATERIALIZED VIEW %s ;", viewName)
if _, err := m.db.Exec(refreshView); err != nil {
return err
}
return nil
}

// GetTestCharts writes the individual test chart data to a map with the keys flakeByDay and flakeByWeek
Expand Down

0 comments on commit 1b887ba

Please sign in to comment.