Skip to content

Commit

Permalink
fix(cache warmup): consider only po of the last 7 days (#1513)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech authored Jan 18, 2025
1 parent 3b5aaab commit 1d2f041
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion controlplane/src/core/repositories/CacheWarmerRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,30 @@ export class CacheWarmerRepository {
}

public async getOperationContent({
rangeInHours,
dateRange,
operationHashes,
federatedGraphID, // TODO; Update view to get operations scoped to the federated graph
organizationID, // TODO; Update view to get operations scoped to the organization
}: {
rangeInHours?: number;
dateRange?: DateRange;
operationHashes: string[];
federatedGraphID: string;
organizationID: string;
}) {
const parsedDateRange = isoDateRangeToTimestamps(dateRange, rangeInHours);
const [start, end] = getDateRange(parsedDateRange);

const query = `
WITH
toDateTime('${start}') AS startDate,
toDateTime('${end}') AS endDate
SELECT
OperationContent as operationContent,
OperationHash as operationHash
FROM ${this.client.database}.gql_metrics_operations
WHERE OperationHash IN (${operationHashes.map((hash) => `'${hash}'`).join(',')})
WHERE Timestamp >= startDate AND Timestamp <= endDate AND OperationHash IN (${operationHashes.map((hash) => `'${hash}'`).join(',')})
GROUP BY
OperationContent,
OperationHash
Expand Down Expand Up @@ -193,6 +203,7 @@ export class CacheWarmerRepository {
operationHashes,
federatedGraphID: props.federatedGraphId,
organizationID: props.organizationId,
rangeInHours: 24 * 7,
});

for (const operation of topOperationsByPlanningTime) {
Expand Down
1 change: 1 addition & 0 deletions demo-router.fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LISTEN_ADDR="0.0.0.0:3002"
LOG_LEVEL="info"
CORS_ALLOW_CREDENTIALS="true"
CLUSTER_NAME="fly-lax"
CACHE_WARMUP_ENABLED="true"

[build]
dockerfile = "./router/Dockerfile"
Expand Down

0 comments on commit 1d2f041

Please sign in to comment.