Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update new-contact-property-change.mjs #8462

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/hubspot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/hubspot",
"version": "0.7.1",
"version": "0.7.2",
"description": "Pipedream Hubspot Components",
"main": "hubspot.app.mjs",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "hubspot-new-contact-property-change",
name: "New Contact Property Change",
description: "Emit new event when a specified property is provided or updated on a contact. [See the docs here](https://developers.hubspot.com/docs/api/crm/contacts)",
version: "0.0.4",
version: "0.0.5",
dedupe: "unique",
type: "source",
props: {
Expand Down Expand Up @@ -107,22 +107,29 @@ export default {
return;
}

const inputs = updatedContacts.map(({ id }) => ({
id,
}));
// get contacts w/ `propertiesWithHistory`
const { results } = await this.batchGetContacts(inputs);

const batchSize = 45;
let maxTs = after;
for (const result of results) {
if (this.isRelevant(result, after)) {
this.emitEvent(result);
const ts = this.getTs(result);
if (ts > maxTs) {
maxTs = ts;

for (let i = 0; i < updatedContacts.length; i += batchSize) {
const batchInputs = updatedContacts.slice(i, i + batchSize).map(({id}) => ({id}));

// get contacts w/ `propertiesWithHistory`
const {results} = await this.batchGetContacts(batchInputs);

maxTs = after;

for (const result of results) {
if (this.isRelevant(result, after)) {
this.emitEvent(result);
const ts = this.getTs(result);
if (ts > maxTs) {
maxTs = ts;
}
}
}
}

after = maxTs;
}

this._setAfter(maxTs);
},
Expand Down