@@ -19,6 +19,7 @@ export interface JobMetrics {
1919export interface SnowflakeExportJob {
2020 id : number
2121 platform : string
22+ sourceName : string
2223 s3Path : string
2324 exportStartedAt : Date | null
2425 createdAt : Date
@@ -35,15 +36,16 @@ export class MetadataStore {
3536
3637 async insertExportJob (
3738 platform : string ,
39+ sourceName : string ,
3840 s3Path : string ,
3941 totalRows : number ,
4042 totalBytes : number ,
4143 exportStartedAt : Date ,
4244 ) : Promise < void > {
4345 const metrics : JobMetrics = { exportedRows : totalRows , exportedBytes : totalBytes }
4446 await this . db . none (
45- `INSERT INTO integration."snowflakeExportJobs" (platform, s3_path, "exportStartedAt", metrics)
46- VALUES ($1, $2, $3, $4::jsonb)
47+ `INSERT INTO integration."snowflakeExportJobs" (platform, "sourceName", s3_path, "exportStartedAt", metrics)
48+ VALUES ($1, $2, $3, $4, $5 ::jsonb)
4749 ON CONFLICT (s3_path) DO UPDATE SET
4850 "exportStartedAt" = EXCLUDED."exportStartedAt",
4951 "processingStartedAt" = NULL,
@@ -52,7 +54,7 @@ export class MetadataStore {
5254 error = NULL,
5355 metrics = EXCLUDED.metrics,
5456 "updatedAt" = NOW()` ,
55- [ platform , s3Path , exportStartedAt , JSON . stringify ( metrics ) ] ,
57+ [ platform , sourceName , s3Path , exportStartedAt , JSON . stringify ( metrics ) ] ,
5658 )
5759 }
5860
@@ -64,6 +66,7 @@ export class MetadataStore {
6466 const row = await this . db . oneOrNone < {
6567 id : number
6668 platform : string
69+ sourceName : string
6770 s3_path : string
6871 exportStartedAt : Date | null
6972 createdAt : Date
@@ -83,7 +86,7 @@ export class MetadataStore {
8386 LIMIT 1
8487 FOR UPDATE SKIP LOCKED
8588 )
86- RETURNING id, platform, s3_path, "exportStartedAt",
89+ RETURNING id, platform, "sourceName", s3_path, "exportStartedAt",
8790 "createdAt", "updatedAt", "processingStartedAt", "completedAt", "cleanedAt", error, metrics` ,
8891 )
8992 return row ? mapRowToJob ( row ) : null
@@ -137,14 +140,15 @@ export class MetadataStore {
137140 )
138141 }
139142
140- async getLatestExportStartedAt ( platform : string ) : Promise < Date | null > {
143+ async getLatestExportStartedAt ( platform : string , sourceName : string ) : Promise < Date | null > {
141144 const row = await this . db . oneOrNone < { max : Date | null } > (
142145 `SELECT MAX("exportStartedAt") AS max
143146 FROM integration."snowflakeExportJobs"
144147 WHERE platform = $1
148+ AND "sourceName" = $2
145149 AND "completedAt" IS NOT NULL
146150 AND error IS NULL` ,
147- [ platform ] ,
151+ [ platform , sourceName ] ,
148152 )
149153 return row ?. max ?? null
150154 }
@@ -153,6 +157,7 @@ export class MetadataStore {
153157function mapRowToJob ( row : {
154158 id : number
155159 platform : string
160+ sourceName : string
156161 s3_path : string
157162 exportStartedAt : Date | null
158163 createdAt : Date
@@ -166,6 +171,7 @@ function mapRowToJob(row: {
166171 return {
167172 id : row . id ,
168173 platform : row . platform ,
174+ sourceName : row . sourceName ,
169175 s3Path : row . s3_path ,
170176 exportStartedAt : row . exportStartedAt ,
171177 createdAt : row . createdAt ,
0 commit comments