Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Add destination delivery mode, cancel duplicate exports when in "once" mode #3009

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rwfeather
Copy link
Contributor

@rwfeather rwfeather commented Feb 25, 2022

Change description

This adds:

  • Delivery mode for destinations. Options are [once, continual]
    • Continual - "Can deliver the same record multiple times" - default
    • Once - "Guaranteed to only deliver a record at-most-once"
  • UI for the destination delivery mode

This changes:

  • Add a check in sendExports that will refuse to run any export whose destination is currently set to "once"

Checklists

Development

  • Application changes have been tested appropriately

Impact

  • Code follows company security practices and guidelines
  • Security impact of change has been considered
  • Performance impact of change has been considered
  • Possible migration needs considered (model migrations, config migrations, etc.)

Please explain any security, performance, migration, or other impacts if relevant:

Code review

  • Pull request has a descriptive title and context useful to a reviewer. Screenshots or screencasts are attached where applicable.
  • Relevant tags have been added to the PR (bug, enhancement, internal, etc.)

@rwfeather rwfeather added the enhancement New feature or request label Feb 25, 2022
@rwfeather rwfeather force-pushed the 181244598-destination-delivery-mode branch from 5f6c380 to d975021 Compare March 1, 2022 17:57
@rwfeather rwfeather force-pushed the 181244598-destination-delivery-mode branch from d442e31 to 61c56ef Compare March 4, 2022 09:16
@rwfeather rwfeather marked this pull request as ready for review March 4, 2022 15:00
@rwfeather
Copy link
Contributor Author

Test is broken in CI but green locally ☹️ . Tracking it down now.

@rwfeather rwfeather force-pushed the 181244598-destination-delivery-mode branch from eb06d87 to 80960d3 Compare March 4, 2022 18:43
@@ -955,6 +955,72 @@ describe("models/destination - with custom exportRecord plugin", () => {
});
});

describe("when destination delivery mode is", () => {
let record: GrouparooRecord = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS note: You don't need to set it to null.

Suggested change
let record: GrouparooRecord = null;
let record: GrouparooRecord;

This makes the record start with a value of undefiend

Comment on lines +970 to +972
afterEach(async () => {
await record.destroy();
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to Export.truncate() between tests as well, to ensure that there is no test polution

@@ -175,6 +175,7 @@ export class DestinationEdit extends AuthenticatedAction {
state: { required: false },
options: { required: false, formatter: APIData.ensureObject },
mapping: { required: false, formatter: APIData.ensureObject },
deliveryMode: { required: false },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change implies that there should be an update to the Action's test as well, confirming that you can set the deliver mode

});
await queryInterface.changeColumn("destinations", "deliveryMode", {
type: DataTypes.STRING(191),
allowNull: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 we end up with a non-nullable column

Comment on lines +173 to +176
@AllowNull(false)
@Default("continual")
@Column(DataType.ENUM(...DELIVERY_MODES))
deliveryMode: DestinationDeliveryMode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably a test to add that foo can't be used as a delivery mode. That's probably going to need a @BeforeSave validation check.

This code here is about setting the types, but it won't validate the data coming in... I think. The test will let us know for sure!

Comment on lines +1023 to +1030
const mostRecentExport = await Export.findOne({
where: {
destinationId: destination.id,
recordId: consideredExport.recordId,
state: "complete",
},
order: [["completedAt", "desc"]],
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method will run for every (const consideredExport of exportsWithChanges), which could be a lot of SQL statements. We'll want to load this data in one SQL statement before the for loop for every export we are considering.

@@ -1,3 +1,4 @@
import { DestinationDeliveryMode } from "@grouparoo/core/src/models/Destination";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't import models from core - this will cause compication problems. The best we can do is import API responses via import { Actions } from "../../../../../utils/apiData"

@pedroslopez pedroslopez removed their request for review March 10, 2022 16:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants