Skip to content

Commit

Permalink
repo-activity: generate list of active repositories and display top 50
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Louis Bright authored and Lars Schneider committed Feb 14, 2018
1 parent 4cf7d08 commit 1adcf56
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/assets/js/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,15 @@ function createTable(table)
.append('th')
.text(d => d);

let displayData = data;
const configSlice = readConfig($(table), 'slice');
if (Array.isArray(configSlice) && configSlice.length > 1)
displayData = data.slice(configSlice[0], configSlice[1]);

let rows = d3.select(table)
.append('tbody')
.selectAll('tr')
.data(data)
.data(displayData)
.enter()
.append('tr');

Expand Down
4 changes: 4 additions & 0 deletions docs/demo-data/repository-activity-detailed.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
repository pushers pushes
some/repo 2 42
other/repo 3 36
last/repo 1 12
11 changes: 11 additions & 0 deletions docs/repos-activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ <h3>Active Repositories in Organizations</h3>
</div>
</div>

<div class="chart-placeholder">
<h3>Most Active Repositories</h3>
<table
data-url="{{ site.dataURL }}/repository-activity-detailed.tsv"
data-config='{"slice": [0, 50]}'
></table>
<div class="info-box">
<p>The top 50 most active repositories by number of pushes.</p>
</div>
</div>

<div class="chart-placeholder">
<h3>Active Repositories in User Accounts</h3>
<canvas
Expand Down
17 changes: 17 additions & 0 deletions updater/reports/ReportRepoActivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def updateDailyData(self):
self.data.extend(newData)
self.truncateData(self.timeRangeTotal())
self.sortDataByDate()
self.detailedHeader, self.detailedData = self.parseData(
self.executeQuery(self.detailedQuery())
)

# Collects active repositories for a user type (user/organization)
# given a time range
Expand Down Expand Up @@ -81,3 +84,17 @@ def query(self):
'''

return query

# Collects the active organizational repositories over the last 4 weeks
def detailedQuery(self):
oneDayAgo = self.yesterday()
fourWeeksAgo = self.daysAgo(28)
query = '''
SELECT
repository,
pusher_count as "pushers",
push_count as "pushes"
FROM (''' + self.activeRepos("Organization", [fourWeeksAgo, oneDayAgo]) + ''') AS activeRepos
ORDER BY push_count DESC
'''
return query

0 comments on commit 1adcf56

Please sign in to comment.