feat: ship self-hosted KOC LOOP workflows
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
type CollectionMcpConfig,
|
||||
} from "./mcp-collection-client";
|
||||
import { uid } from "./mvp-db";
|
||||
import type { DatabaseClient, DatabaseStatement } from "./database";
|
||||
|
||||
type DistributionForCollection = {
|
||||
id: string;
|
||||
@@ -84,7 +85,7 @@ function dueSchedules(
|
||||
}
|
||||
|
||||
export async function createCollectionRunTasks(
|
||||
db: D1Database,
|
||||
db: DatabaseClient,
|
||||
taskId: string,
|
||||
startDate: string,
|
||||
days: number[],
|
||||
@@ -111,7 +112,7 @@ export async function createCollectionRunTasks(
|
||||
.bind(taskId)
|
||||
.run();
|
||||
|
||||
const statements: D1PreparedStatement[] = [];
|
||||
const statements: DatabaseStatement[] = [];
|
||||
for (const distribution of distributions.results) {
|
||||
for (const scheduleDay of normalizedDays) {
|
||||
const scheduledDate = dateForScheduleDay(startDate, scheduleDay);
|
||||
@@ -147,7 +148,7 @@ export async function createCollectionRunTasks(
|
||||
}
|
||||
|
||||
export async function collectDistributionMetrics(
|
||||
db: D1Database,
|
||||
db: DatabaseClient,
|
||||
distributionId: string,
|
||||
scheduledDate: string,
|
||||
scheduleDay: number | null,
|
||||
@@ -310,7 +311,7 @@ export async function collectDistributionMetrics(
|
||||
}
|
||||
|
||||
export async function runScheduledCollections(
|
||||
db: D1Database,
|
||||
db: DatabaseClient,
|
||||
scheduledTimestamp: number,
|
||||
mcpConfig: CollectionMcpConfig,
|
||||
) {
|
||||
@@ -323,7 +324,7 @@ export async function runScheduledCollections(
|
||||
}
|
||||
|
||||
export async function runDueScheduledCollections(
|
||||
db: D1Database,
|
||||
db: DatabaseClient,
|
||||
timestamp: number,
|
||||
mcpConfig: CollectionMcpConfig,
|
||||
source: Extract<CollectionSource, "automatic" | "catchup"> = "catchup",
|
||||
@@ -404,7 +405,7 @@ export async function runDueScheduledCollections(
|
||||
}
|
||||
|
||||
export async function retryFailedCollections(
|
||||
db: D1Database,
|
||||
db: DatabaseClient,
|
||||
taskId: string,
|
||||
mcpConfig: CollectionMcpConfig,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user