-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(ga): sync ga data lambda #93
Conversation
startDate, | ||
endDate, |
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.
shall we need to check dates here? startDate <= endDate
?
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.
invalid input would fail the GA4 api request
|
||
export const getLocalDateString = (date: Date) => { | ||
// return utc+8 date string in YYYY-MM-DD format | ||
return date.toLocaleDateString("sv", { timeZone: "Asia/Taipei" }); |
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.
is this sv
using a Swedish locale? maybe toISOString
is better? does here require a UTC+8 timezone cutoff of each day?
> (new Date).toISOString().substring(0, 10)
'2023-11-14'
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.
does here require a UTC+8 timezone cutoff of each day?
Yes, as GA4 timezone settings is UTC+8
} | ||
} | ||
if (insertRows.length > 0) { | ||
await knex(TABLE_NAME).insert(insertRows); |
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.
and do you have estimation of how many rows will be there each day? what's growth estimation of this table per month;
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.
and there's a way to upsert might be useful in the case, one line to handle all rows:
INSERT INTO table (...) VALUES (...)
ON CONFLICT (id)
DO UPDATE SET total_users=EXCLUDED.total_users ;
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.
upsert way doesn't work here, because table article_ga4_data
has an exclusion constraint which ON CONFLICT
syntax doesn't support
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.
do you have estimation of how many rows will be there each day? what's growth estimation of this table per month;
roughly 6k rows a day
No description provided.