Skip to content

Commit

Permalink
backfill bridges every hour
Browse files Browse the repository at this point in the history
  • Loading branch information
vrtnd committed Sep 9, 2024
1 parent f1729f9 commit 22a80e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ functions:
timeout: 900
memorySize: 250
events:
- schedule: cron(2,17,47 * * * ? *)
- schedule: cron(10,25,40 * * * ? *)
runAggregateAllAdapters:
handler: src/handlers/runAggregateAllAdapters.default
timeout: 900
Expand All @@ -158,7 +158,7 @@ functions:
timeout: 900
memorySize: 1024
events:
- schedule: cron(0 0,12 * * ? *)
- schedule: cron(1 * * * ? *)
dailyAggregateAllAdapters:
handler: src/handlers/dailyAggregateAllAdapters.default
timeout: 900
Expand Down
24 changes: 8 additions & 16 deletions src/handlers/runAllAdaptersHistorical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,14 @@ async function invokeLambda(functionName: string, event: any) {
const handler = async (_event: any) => {
await closeIdleConnections();
const now = Math.floor(Date.now() / 1000);
const oneDayAgo = now - 86400;
const halfDayAgo = now - 43200;

const timeRanges = [
{ start: oneDayAgo, end: halfDayAgo },
{ start: halfDayAgo, end: now },
];

for (const timeRange of timeRanges) {
for (const bridge of bridgeNetworks) {
await invokeLambda("llama-bridges-prod-runAdapterFromTo", {
bridgeName: bridge.bridgeDbName,
fromTimestamp: timeRange.start,
toTimestamp: timeRange.end,
});
}
const oneHourAgo = now - 3600;

for (const bridge of bridgeNetworks) {
await invokeLambda("llama-bridges-prod-runAdapterFromTo", {
bridgeName: bridge.bridgeDbName,
fromTimestamp: oneHourAgo,
toTimestamp: now,
});
}

console.log("Initiated historical runs for all adapters");
Expand Down

0 comments on commit 22a80e8

Please sign in to comment.