-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1cfc71
commit 9e5b42d
Showing
32 changed files
with
1,238 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: cron | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'packages/cron/**' | ||
- '.github/workflows/cron.yml' | ||
pull_request: | ||
paths: | ||
- 'packages/cron/**' | ||
- '.github/workflows/cron.yml' | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
name: Test | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- uses: bahmutov/npm-install@v1 | ||
- run: npm test --workspace packages/cron |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env node | ||
|
||
import dotenv from 'dotenv' | ||
import { refreshMaterializedViews } from '../jobs/dagcargo.js' | ||
import { getPg } from '../lib/utils.js' | ||
|
||
async function main () { | ||
const pg = getPg(process.env) | ||
await pg.connect() | ||
|
||
try { | ||
await refreshMaterializedViews({ pg }) | ||
} finally { | ||
await pg.end() | ||
} | ||
} | ||
|
||
dotenv.config() | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import debug from 'debug' | ||
|
||
/** | ||
* Refreshes the materialized views. | ||
* | ||
* @param {{ pg: import('pg').Client }} config | ||
*/ | ||
export async function refreshMaterializedViews ({ pg }) { | ||
const log = debug('dagcargo:refreshMaterializedViews') | ||
if (!log.enabled) { | ||
console.log( | ||
'ℹ️ Enable logging by setting DEBUG=dagcargo:refreshMaterializedViews' | ||
) | ||
} | ||
|
||
log('🔁 REFRESH MATERIALIZED VIEW CONCURRENTLY public.deal;') | ||
await pg.query('REFRESH MATERIALIZED VIEW CONCURRENTLY public.deal;') | ||
|
||
log('🔁 REFRESH MATERIALIZED VIEW CONCURRENTLY public.aggregate;') | ||
await pg.query('REFRESH MATERIALIZED VIEW CONCURRENTLY public.aggregate;') | ||
|
||
log('🔁 REFRESH MATERIALIZED VIEW CONCURRENTLY public.aggregate_entry;') | ||
await pg.query('REFRESH MATERIALIZED VIEW CONCURRENTLY public.aggregate_entry;') | ||
|
||
log('✅ Done') | ||
} |
Oops, something went wrong.