Skip to content

Commit 7fc24f9

Browse files
committed
some adjusts
1 parent 95ff67f commit 7fc24f9

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

components/agentset/common/utils.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ export const parseObject = (obj) => {
3131
}
3232
return obj;
3333
};
34+
35+
export const prepareDateTime = (data) => {
36+
return data.completedAt ||
37+
data.failedAt ||
38+
data.processingAt ||
39+
data.preProcessingAt ||
40+
data.queuedAt ||
41+
data.createdAt;
42+
};

components/agentset/sources/common/base.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
22
import agentset from "../../agentset.app.mjs";
3+
import { prepareDateTime } from "../../common/utils.mjs";
34

45
export default {
56
props: {
@@ -49,7 +50,8 @@ export default {
4950

5051
let responseArray = [];
5152
for await (const item of response) {
52-
if (Date.parse(item.createdAt) <= lastData) break;
53+
const dateTime = prepareDateTime(item);
54+
if (Date.parse(dateTime) <= lastData) break;
5355
responseArray.push(item);
5456
}
5557

@@ -58,10 +60,11 @@ export default {
5860
}
5961

6062
for (const item of responseArray.reverse()) {
63+
const dateTime = prepareDateTime(item);
6164
this.$emit(item, {
6265
id: `${item.id}-${item.status}`,
6366
summary: this.getSummary(item),
64-
ts: Date.parse(item.createdAt),
67+
ts: Date.parse(dateTime),
6568
});
6669
}
6770
},

components/agentset/sources/new-document/new-document.mjs renamed to components/agentset/sources/document-status-updated/document-status-updated.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import sampleEmit from "./test-event.mjs";
33

44
export default {
55
...common,
6-
key: "agentset-new-document",
7-
name: "New Document Status",
8-
description: "Emit new event when a new document status is updated. [See the documentation](https://docs.agentset.ai/api-reference/endpoint/documents/list)",
6+
key: "agentset-document-status-updated",
7+
name: "Document Status Updated",
8+
description: "Emit new event when a document status is updated. [See the documentation](https://docs.agentset.ai/api-reference/endpoint/documents/list)",
99
version: "0.0.1",
1010
type: "source",
1111
dedupe: "unique",
@@ -15,7 +15,7 @@ export default {
1515
return this.agentset.listDocuments;
1616
},
1717
getSummary(item) {
18-
return `New Document: ${item.name || item.id}`;
18+
return `Document ${item.name || item.id} has a new status: ${item.status}`;
1919
},
2020
},
2121
sampleEmit,

components/agentset/sources/new-ingest-job/new-ingest-job.mjs renamed to components/agentset/sources/ingest-job-status-updated/ingest-job-status-updated.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import sampleEmit from "./test-event.mjs";
33

44
export default {
55
...common,
6-
key: "agentset-new-ingest-job",
7-
name: "New Ingest Job Status",
8-
description: "Emit new event when a new ingest job status is updated. [See the documentation](https://docs.agentset.ai/api-reference/endpoint/ingest-jobs/list)",
6+
key: "agentset-ingest-job-status-updated",
7+
name: "Ingest Job Status Updated",
8+
description: "Emit new event when a ingest job status is updated. [See the documentation](https://docs.agentset.ai/api-reference/endpoint/ingest-jobs/list)",
99
version: "0.0.1",
1010
type: "source",
1111
dedupe: "unique",
@@ -15,7 +15,7 @@ export default {
1515
return this.agentset.listIngestJobs;
1616
},
1717
getSummary(item) {
18-
return `New Ingest Job: ${item.id}`;
18+
return `Ingest Job (${item.id}) has a new status: ${item.status}`;
1919
},
2020
},
2121
sampleEmit,

0 commit comments

Comments
 (0)