-
Notifications
You must be signed in to change notification settings - Fork 115
Add destination delivery mode, cancel duplicate exports when in "once" mode #3009
base: main
Are you sure you want to change the base?
Conversation
5f6c380
to
d975021
Compare
d442e31
to
61c56ef
Compare
Test is broken in CI but green locally |
eb06d87
to
80960d3
Compare
@@ -955,6 +955,72 @@ describe("models/destination - with custom exportRecord plugin", () => { | |||
}); | |||
}); | |||
|
|||
describe("when destination delivery mode is", () => { | |||
let record: GrouparooRecord = null; |
There was a problem hiding this comment.
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.
let record: GrouparooRecord = null; | |
let record: GrouparooRecord; |
This makes the record start with a value of undefiend
afterEach(async () => { | ||
await record.destroy(); | ||
}); |
There was a problem hiding this comment.
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 }, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
@AllowNull(false) | ||
@Default("continual") | ||
@Column(DataType.ENUM(...DELIVERY_MODES)) | ||
deliveryMode: DestinationDeliveryMode; |
There was a problem hiding this comment.
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!
const mostRecentExport = await Export.findOne({ | ||
where: { | ||
destinationId: destination.id, | ||
recordId: consideredExport.recordId, | ||
state: "complete", | ||
}, | ||
order: [["completedAt", "desc"]], | ||
}); |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"
Change description
This adds:
This changes:
sendExports
that will refuse to run any export whose destination is currently set to "once"Checklists
Development
Impact
Please explain any security, performance, migration, or other impacts if relevant:
Code review