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

Add discussion metrics weekly slack message #673

Merged

Conversation

hubertdeng123
Copy link
Member

@hubertdeng123 hubertdeng123 commented Oct 25, 2023

This adds a weekly discussion metrics slack message. It'll look something like this:
Screenshot 2023-10-24 at 5 10 07 PM

It'll show the top 5 most active discussions and 5 most active Sentaurs]

part of getsentry/team-ospo#165

@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Files Coverage Δ
src/utils/scores.ts 100.00% <100.00%> (ø)
src/webhooks/pubsub/slackScores.ts 100.00% <100.00%> (ø)
src/config/index.ts 97.08% <50.00%> (-0.96%) ⬇️

📢 Thoughts on this report? Let us know!.

Comment on lines +108 to +123
SELECT
discussions.username as username,
COUNT(discussions.username) as num_comments,
FROM
\`open_source.github_events\` AS discussions
WHERE
discussions.type = 'discussion_comment'
AND timestamp_diff(
CURRENT_TIMESTAMP(),
discussions.created_at,
day
) <= 7
AND discussions.user_type != 'external'
AND discussions.user_type != 'bot'
GROUP BY discussions.username
ORDER BY num_comments DESC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope for this PR, but I wonder if there is some standard way of running a local in-memory instance of SQLite to query against, or something similar? Otherwise we end up with a ton of untested code: we validate that the exact text of our SQL code is what we expect, but not what that SQL code actually does (ie, does it get the exact rows in the table we want it to?).

I could imagine using in-memory SQLite as our backend, since this looks like bog-standard SQL with no BigQuery specific extensions in it.

Just a thought - not a blocker by any means, and definitely not a thing to do in this PR, but something to think about, since we've had a few cases of queries not returning the data set we expect them to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that'd be nice to just to get some validation that it's valid sql. Adding to the backlog of things to do for eng-pipes:
#676

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but yes, the dev environment setup for BigQuery leaves much to be desired....

I don't think most people who have worked in eng-pipes have even hooked up their env to BigQuery

@@ -45,67 +67,67 @@ describe('slackScores Tests', function () {
| null | - (0/0) |
| ospo | - (0/0) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we always report ospo, even when no metrics are returned? Or is that just how the test is configured?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just how the test is configured, it uses the teams in test/product-owners.yml

];
const discussionCommenters = [
{
username: 'luke_skywalker',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a golden opportunity to have one of the commenters be chewbacca:

Chewbacca, 3 hours ago:
--------
Raaaaa-ra-ra awwww raaaaa!

- Sent from my iPhone 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right 🤦‍♂️

discussionCommenters,
});
await sendDiscussionMetrics();
// Columns with links in them may seem a bit off, because the links won't actually appear in slack
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to fix this? Or does it basically require running the code through a markdown parser?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will require us to run the code through a markdown parser, looks nasty in tests but it's well formed in slack!

@hubertdeng123 hubertdeng123 merged commit 4cb8337 into main Oct 25, 2023
8 checks passed
@hubertdeng123 hubertdeng123 deleted the hubertdeng123/add-discussion-metrics-slack-message branch October 25, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants