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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gh #783 more context #795

Merged
merged 2 commits into from
Jul 18, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/shared/lib/clients/sync.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ class SyncClient {
accountId: accountId,
metadata: {
syncName,
connectionDetails: nangoConnection,
connectionDetails: JSON.stringify(nangoConnection),
syncId: sync.id,
syncConfig
syncConfig,
syncData: JSON.stringify(syncData)
}
});
}
Expand Down
18 changes: 18 additions & 0 deletions packages/shared/lib/services/nango-config.service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, describe, it } from 'vitest';
import * as NangoConfigService from './nango-config.service.js';

describe('Nango Config Interval tests', () => {
it('throws error when interval is less than 5 minutes', async () => {
expect(() => NangoConfigService.getInterval('every 4m', new Date())).toThrow('interval must be greater than 5 minutes');
});
it('Can parse every half day', async () => {
const date = new Date('2023-07-18T00:00:00');
expect(NangoConfigService.getInterval('every half day', date)).toEqual({ interval: '12h', offset: 0 });
const tenMinutes = new Date('2023-07-18T00:10:00');
expect(NangoConfigService.getInterval('every half day', tenMinutes)).toEqual({ interval: '12h', offset: 600000 });
});
it('Can parse every 1.5 hours', async () => {
const date = new Date('2023-07-18T00:00:00');
expect(NangoConfigService.getInterval('every 1.5 hours', date)).toEqual({ interval: '1.5 hours', offset: 0 });
});
});
4 changes: 4 additions & 0 deletions packages/shared/lib/services/nango-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ export function getOffset(interval: string, date: Date): number {
* greater than the interval
*/
export function getInterval(runs: string, date: Date): { interval: string; offset: number } {
if (runs === 'every half day') {
return { interval: '12h', offset: getOffset('12h', date) };
}

if (runs === 'every half hour') {
return { interval: '30m', offset: getOffset('30m', date) };
}
Expand Down