-
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
819c9e0
commit f5f99bd
Showing
31 changed files
with
2,308 additions
and
1,292 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 |
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,22 @@ To run this locally you will need the following in your `packages/cron/.env` fil | |
|
||
```ini | ||
ENV=dev | ||
DATABASE=postgres | ||
|
||
# PostgREST API URL | ||
DEV_PG_REST_URL=http://localhost:3000 | ||
# PostgREST API token, for role "postgres", using secret value PGRST_JWT_SECRET from './postgres/docker/docker-compose.yml' | ||
# https://postgrest.org/en/v8.0/tutorials/tut1.html#step-3-sign-a-token | ||
DEV_PG_REST_JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoicG9zdGdyZXMifQ.oM0SXF31Vs1nfwCaDxjlczE237KcNKhTpKEYxMX-jEU | ||
|
||
# Connection string for locally running postgres used in tests | ||
DEV_PG_CONNECTION=postgres://postgres:[email protected]:5432/postgres | ||
|
||
# Cluster | ||
CLUSTER_API_URL=http://127.0.0.1:9094/ | ||
CLUSTER_IPFS_PROXY_API_URL=http://127.0.0.1:9095/api/v0/ | ||
|
||
# Fauna | ||
DEV_FAUNA_KEY="<your key here>" | ||
``` | ||
|
||
|
@@ -31,25 +45,3 @@ Run the job: | |
```sh | ||
npm run start:pins | ||
``` | ||
|
||
### pinata | ||
|
||
Fetch the oldest 600 PinRequests from the DB and pin them on Piñata | ||
|
||
To run this locally you will need the following in your `packages/cron/.env` file: | ||
|
||
```ini | ||
ENV=dev | ||
DEV_FAUNA_KEY="<your key here>" | ||
PINATA_JWT="<your jwt here>" | ||
``` | ||
|
||
You also need to have: | ||
|
||
- a dev account and db set up on FaunaDB with the latest schema imported as per [../db/README.md](../db/README.md) | ||
|
||
Run the job: | ||
|
||
```sh | ||
npm run start:pinata | ||
``` |
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') | ||
} |
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
Oops, something went wrong.