Skip to content

Add API Requests By User #148

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/demo-data/api-requests-by-user.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
user requests
Alpha 1500
Bravo 500
Charlie 20
14 changes: 14 additions & 0 deletions docs/housekeeping-api-requests.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ <h3>API Requests</h3>
</div>
</div>

<div class="chart-placeholder">
<h3>Top API Requests by Users</h3>
Copy link
Contributor

@pluehne pluehne Apr 23, 2018

Choose a reason for hiding this comment

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

I’d drop the “Top” in the title, because it’s common for our charts only to show the top entries (for instance, in the Git traffic table).

<canvas
data-url="{{ site.dataURL }}/api-requests-by-user.tsv"
data-type="list"
></canvas>
<div class="info-box">
<p>
The top 20 users with the most API requests.
</p>
</div>
</div>


<div class="chart-placeholder">
<table data-url="{{ site.dataURL }}/api-requests-detailed.tsv" data-type="table"></table>
<div class="info-box">
Expand Down
13 changes: 13 additions & 0 deletions updater/reports/ReportAPIRequestsByUser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from .Report import *


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 add a short description of this report as a comment, as we have with the other reports?

class ReportAPIRequestsByUser(Report):

def name(self):
return "api-requests-by-user"

def readData(self):
pass

def updateData(self):
self.header, self.data = self.parseData(self.executeScript(self.scriptPath("api-requests-by-user.sh")))
17 changes: 17 additions & 0 deletions updater/scripts/api-requests-by-user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

#
# Count number of API calls per user
#

echo -e "user\trequests"

zcat -f /var/log/github/unicorn.log.1* |
grep request_category=api |
grep -oP 'current_user=\K\S+' |
grep -v ^nil$ |
sort |
uniq -c |
sort -rn |
head -20 |
awk '{ printf("%s\t%s\n", $2, $1) }'
2 changes: 2 additions & 0 deletions updater/update-stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from schema import *

from reports.ReportAPIRequests import *
from reports.ReportAPIRequestsByUser import *
from reports.ReportContributorsByOrg import *
from reports.ReportContributorsByRepo import *
from reports.ReportForksToOrgs import *
Expand Down Expand Up @@ -74,6 +75,7 @@ def main():

# Update reports
ReportAPIRequests(configuration, dataDirectory, metaStats).update()
ReportAPIRequestsByUser(configuration, dataDirectory, metaStats).update()
ReportContributorsByOrg(configuration, dataDirectory, metaStats).update()
ReportContributorsByRepo(configuration, dataDirectory, metaStats).update()
ReportForksToOrgs(configuration, dataDirectory, metaStats).update()
Expand Down