Skip to content

Commit

Permalink
Merge pull request #886 from jboolean/reviewer-stats
Browse files Browse the repository at this point in the history
Include reviewer stats in stale stories email
  • Loading branch information
jboolean authored Sep 16, 2023
2 parents be82358 + d730812 commit d3039a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Senders from './Senders';
type StoryEmailTemplateData = {
storiesCount: number;
reviewStoriesUrl: string;
stats: { reviewer: string; count: number }[];
};

class ReviewQueueStaleTemplate extends EmailTemplate<
Expand Down
12 changes: 12 additions & 0 deletions backend/src/cron/checkStaleStories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ function forgeReviewStoriesUrl(): string {
return storyEditUrl.toString();
}

async function getReviewerStats(): Promise<
{ reviewer: string; count: number }[]
> {
const stats = (await StoryRepository().query(
`select last_reviewer as reviewer, count(*) as count from stories where last_reviewer is not null group by last_reviewer order by count(*) desc;`
)) as Promise<{ reviewer: string; count: number }[]>;
return stats;
}

export default async function checkStaleStories(): Promise<void> {
const hasStaleStories =
(await StoryRepository()
Expand All @@ -34,10 +43,13 @@ export default async function checkStaleStories(): Promise<void> {

const reviewStoriesUrl = forgeReviewStoriesUrl();

const stats = await getReviewerStats();

const email = ReviewQueueStaleTemplate.createTemplatedEmail({
templateContext: {
reviewStoriesUrl,
storiesCount,
stats,
},
metadata: {},
to: process.env.MODERATORS_TO_EMAIL ?? '',
Expand Down

0 comments on commit d3039a9

Please sign in to comment.