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 new Discussions plugin #430

Merged
merged 5 commits into from
Jul 30, 2021
Merged

Add new Discussions plugin #430

merged 5 commits into from
Jul 30, 2021

Conversation

lowlighter
Copy link
Owner

Add new discussion plugin to display how many discussion user has started, and how many comments and answers provided.
Also track most posted categories
lowlighter

Co-authored-by: Nixinova <nixinova@gmail.com>
@lowlighter lowlighter merged commit 88f9e1a into master Jul 30, 2021
@lowlighter lowlighter deleted the feat-plugin-discussions branch July 30, 2021 21:05
do {
console.debug(`metrics/compute/${login}/discussions > retrieving discussions after ${cursor}`)
const {user:{repositoryDiscussions:{edges = [], nodes = []} = {}}} = await graphql(queries.discussions.categories({login, after:cursor ? `after: "${cursor}"` : ""}))
cursor = edges?.[edges?.length - 1]?.cursor
Copy link
Contributor

Choose a reason for hiding this comment

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

Super minor nitpick, but I think

edges?.[edges?.length - 1]

has a slightly redundant check. If edges == null, the expression inside the brackets shouldn't be evaluated.
For example

const foo = void 0;
foo?.[foo.bar] // undefined, doesn't throw error

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes I think you're right 🙂

Eventually I'd like to move to Array.at with edges.at(-1)?.cursor which seems cleaner, but I'm not sure that both node used version and vercel's one currently support it

Copy link
Contributor

Choose a reason for hiding this comment

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

Array#at was added to Node literally yesterday.

@Nixinova
Copy link
Contributor

Nixinova commented Aug 1, 2021

Can discussions be moved to be under followup? Thats a more natural position than at the end.

@lowlighter
Copy link
Owner Author

Yes it would makes more sense.
You can patch source/templates/classic/partials/_.json if you want 👍

@lowlighter lowlighter mentioned this pull request Aug 2, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Aug 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants