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

Change date schema to be compatible with ortto schema #108

Merged
merged 5 commits into from
Jul 22, 2024
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
11 changes: 8 additions & 3 deletions src/services/notificationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('activityCreator', () => {
it('should create attributes for NOTIFY_REWARD_AMOUNT', () => {
const payload = {
round: 1,
date: '2024-06-01',
date: '1721668910580',
amount: '1000',
contractAddress: '0x123',
farm: 'Test Farm',
Expand All @@ -24,10 +24,15 @@ describe('activityCreator', () => {
JSON.stringify({
activities: [
{
activity_id: 'act:cm:notify-reward-amount',
activity_id: 'act:cm:notify-reward',
attributes: {
'dtz:cm:date': {
year: 2024,
month: 7,
day: 22,
timezone: 'UTC',
},
'int:cm:round': payload.round,
'str:cm:date': payload.date,
'str:cm:amount': payload.amount,
'str:cm:contractaddress': payload.contractAddress,
'str:cm:farm': payload.farm,
Expand Down
9 changes: 8 additions & 1 deletion src/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const activityCreator = (
orttoEventName: NOTIFICATIONS_EVENT_NAMES,
): any => {
let attributes;
let date;
switch (orttoEventName) {
case NOTIFICATIONS_EVENT_NAMES.SUBSCRIBE_ONBOARDING:
attributes = {
Expand Down Expand Up @@ -179,9 +180,15 @@ export const activityCreator = (
};
break;
case NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT:
date = new Date(Number(payload.date));
attributes = {
'dtz:cm:date': {
year: date.getUTCFullYear(),
month: date.getUTCMonth() + 1, // JavaScript's months are zero-indexed
day: date.getUTCDate(),
timezone: 'UTC',
},
'int:cm:round': payload.round,
'str:cm:date': payload.date,
'str:cm:amount': payload.amount,
'str:cm:contractaddress': payload.contractAddress,
'str:cm:farm': payload.farm,
Expand Down
2 changes: 1 addition & 1 deletion src/types/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ export const ORTTO_EVENT_NAMES = {
[NOTIFICATIONS_EVENT_NAMES.CREATE_ORTTO_PROFILE]: 'created-profile',
[NOTIFICATIONS_EVENT_NAMES.SEND_EMAIL_CONFIRMATION]:
'verification-form-email-verification',
[NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT]: 'notify-reward-amount',
[NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT]: 'notify-reward',
[NOTIFICATIONS_EVENT_NAMES.SUBSCRIBE_ONBOARDING]: 'onboarding-form',
};
Loading