refactor(flickr): add isAlreadyProcessed for greatest dedupe strategy
This commit is contained in:
@@ -6,7 +6,7 @@ export default defineTrigger({
|
|||||||
pollInterval: 15,
|
pollInterval: 15,
|
||||||
key: 'newPhoto',
|
key: 'newPhoto',
|
||||||
description: 'Triggers when you add a new photo.',
|
description: 'Triggers when you add a new photo.',
|
||||||
dedupeStrategy: 'unique',
|
dedupeStrategy: 'greatest',
|
||||||
substeps: [
|
substeps: [
|
||||||
{
|
{
|
||||||
key: 'chooseConnection',
|
key: 'chooseConnection',
|
||||||
|
@@ -87,16 +87,26 @@ const globalVariable = async (
|
|||||||
beforeRequest: app.beforeRequest,
|
beforeRequest: app.beforeRequest,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (trigger && trigger.dedupeStrategy === 'unique') {
|
if (trigger) {
|
||||||
const lastInternalIds = testRun ? [] : await flow?.lastInternalIds();
|
if (trigger.dedupeStrategy === 'unique') {
|
||||||
|
const lastInternalIds = testRun ? [] : await flow?.lastInternalIds();
|
||||||
|
|
||||||
const isAlreadyProcessed = (internalId: string) => {
|
const isAlreadyProcessed = (internalId: string) => {
|
||||||
if (testRun) return false;
|
if (testRun) return false;
|
||||||
|
|
||||||
return lastInternalIds?.includes(internalId);
|
return lastInternalIds?.includes(internalId);
|
||||||
};
|
};
|
||||||
|
|
||||||
$.flow.isAlreadyProcessed = isAlreadyProcessed;
|
$.flow.isAlreadyProcessed = isAlreadyProcessed;
|
||||||
|
} else if (trigger.dedupeStrategy === 'greatest') {
|
||||||
|
const isAlreadyProcessed = (internalId: string) => {
|
||||||
|
if (testRun) return false;
|
||||||
|
|
||||||
|
return Number(internalId) <= Number($.flow.lastInternalId);
|
||||||
|
};
|
||||||
|
|
||||||
|
$.flow.isAlreadyProcessed = isAlreadyProcessed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $;
|
return $;
|
||||||
|
Reference in New Issue
Block a user