-
Notifications
You must be signed in to change notification settings - Fork 267
Implement weekly email schedule job #2022
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
Conversation
6602187 to
a8ca59c
Compare
| .selectDistinct({ workspaceId: spans.workspaceId }) | ||
| .from(spans) | ||
| .where( | ||
| and(eq(spans.type, SpanType.Prompt), gte(spans.startedAt, fourWeeksAgo)), |
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.
Active workspace definition in terms of traces
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.
can potentially time out in production, keep an eye on it
|
|
||
| // Enqueue individual cleanup job for each free workspace | ||
| for (const workspace of freeWorkspaces) { | ||
| const { maintenanceQueue } = await queues() |
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 ok? I think it can be shared between iterations
| } | ||
| }), | ||
| ) | ||
| await mailer.sendInBatches({ |
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.
I DRYed and now this is how can send emails in batches. Meaning same email template will be sent to all the addressList. The limitation here is that a batch email can not have personalized info by email/user. In the case of this weekly email is fine.
56e4154 to
960b3f6
Compare
960b3f6 to
b79ae3f
Compare
We want to send an email with relevant data for the organizations using Latitude. We'll do the processing of this data on monday 1:00 A.M and it will be sent to be ready on users' inbox on monday morning
b79ae3f to
6333616
Compare
| .action(async ({ parsedInput }) => { | ||
| const { workspaceId, emails } = parsedInput | ||
|
|
||
| // Parse comma-separated emails if provided |
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.
remove ai comments when possible
| import { ScoreCell } from './ScoreCell' | ||
| import { cn } from '@latitude-data/web-ui/utils' | ||
| import { formatCount } from '$/lib/formatCount' | ||
| import { formatCount } from '@latitude-data/constants/formatCount' |
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.
weird that constants exposes a function
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.
But is a really nice method and I want to share it between apps/web and packages/email. Constants is the right place. Constants could have been called in other way. I agree on that.
| inArray(issueHistograms.issueId, newIssueIds), | ||
| ), | ||
| ) | ||
| .as('latestHistogram') |
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.
why this complexity the n of issues/histograms in a workspace is minuscule
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 is getting the latest histogram produced for the issue to get the most recent commit where that issue occurred. I want the commit.uuid to build the URL to point to the right issue details on the right commit in issues dashboard
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.
can't you select distinct with a limit? don't know why the window function
| .where(inArray(issues.id, newIssueIds)) | ||
| .orderBy(desc(issues.createdAt)) | ||
| .limit(10) | ||
| } |
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.
having trouble understanding this query with the previous histogram subquery. Couldn't you just fetch the latest histograms by ocurred at ordering and select distinct issue id and then filter by those in this query?
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.
What?
We want to send an email with relevant data for the organizations using Latitude. We'll do the processing of this data on monday, 1:00 A.M and it will be sent to be ready on users' inboxes on Monday morning
TODO
livecommit and in new issues, use the commit we have.livecommit.