Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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