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 repo usage report #112

Merged
merged 4 commits into from
Feb 5, 2018
Merged

add repo usage report #112

merged 4 commits into from
Feb 5, 2018

Conversation

larsxschneider
Copy link
Collaborator

Calculate percentage of active repositories over the last four weeks
in organizations that have received pushes to at least one protected
branch and that have at least one topic assigned to them.

This way we can track if people use protected branches and topics!


Please review by commit. 1-3 are preparation, 4 is the beef 😄

</div>
<div class="info-box">
<p>
Repositories are counted as <em>active</em> if they received at
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put this on one line?

Copy link
Contributor

@pluehne pluehne left a comment

Choose a reason for hiding this comment

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

I like this report, that’s an interesting metric. Some minor remarks below 😄.

subnavigation:
- title: "Feature Usage"
Copy link
Contributor

@pluehne pluehne Feb 5, 2018

Choose a reason for hiding this comment

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

Good title for reports of this kind (no irony intended)!

query = '''
SELECT
"''' + str(oneDayAgo) + '''" AS date,
ROUND(100*COUNT(DISTINCT(protect.repository_id))/COUNT(DISTINCT(active.repository_id)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put spaces around the arithmetic operators for consistency?

Copy link
Contributor

@pluehne pluehne Feb 5, 2018

Choose a reason for hiding this comment

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

Also, isn’t a float conversion desirable here to avoid an integer division?

Copy link
Contributor

Choose a reason for hiding this comment

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

For the record, MySQL seems to perform a float division with / in all cases, while integer divisions require the DIV keyword. That’s strange, because other SQL implementations handle this differently as it seems …

"''' + str(oneDayAgo) + '''" AS date,
ROUND(100*COUNT(DISTINCT(protect.repository_id))/COUNT(DISTINCT(active.repository_id)))
AS "protected branches [%]",
ROUND(100*COUNT(DISTINCT(topics.repository_id))/COUNT(DISTINCT(active.repository_id)))
Copy link
Contributor

Choose a reason for hiding this comment

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

See above ☝️.

(
SELECT
repositories.id AS repository_id,
ref
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you write repositories.ref (if that’s the right one)? I had trouble seeing where ref comes from.

LEFT JOIN (
SELECT repository_id, name
FROM protected_branches
) AS protect ON active.repository_id = protect.repository_id AND active.ref = "refs/heads/" + protect.name
Copy link
Contributor

Choose a reason for hiding this comment

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

I’d abbreviate “protected Branches” as protected instead of protect, but that’s not really an issue.

Lars Schneider added 4 commits February 5, 2018 18:58
Align query for active repos and add a comment to keep them aligned.
In the future we might want to refactor the "active repo" code into a
reusable function.

Although the updated query excludes entities, I don't expect the data
to change in any significant way as there is usually no activity on
the excluded entities anyways.
Calculate percentage of active repositories over the last four weeks
in organizations that have received pushes to at least one protected
branch and that have at least one topic assigned to them.
@pluehne pluehne merged commit cb52594 into master Feb 5, 2018
@pluehne pluehne deleted the repo-activity branch February 5, 2018 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants