Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add a chart to the distribution api docs

  • Loading branch information...
commit 4f4b037ed73f91e611eea157f113fb90ad01c64b 1 parent bfe1eba
Ionuț Arțăriși authored
Showing with 46 additions and 18 deletions.
  1. +31 −16 popcorn/templates/distro_doc.html
  2. +15 −2 popcorn/views.py
47 popcorn/templates/distro_doc.html
View
@@ -1,29 +1,44 @@
{% extends "layout.html" %}
-{% block content %}
+{% block javascript %}
+<script type="text/javascript" src="https://www.google.com/jsapi"></script>
+<script type="text/javascript">
+ google.load('visualization', '1', {'packages':['corechart']});
-<h2>Distribution</h2>
+ {% include "js/submissions_distrover.js" %}
+</script>
+{% endblock %}
-<p>Information related to the distributions installed on the systems
-that popcorn submissions are received from.</p>
+{% block content %}
+<div class="row-fluid">
+ <div class="span7">
+ <h2>Distribution</h2>
-<h3 id="show-a-distribution">Show a distribution</h3>
+ <p>Information related to the distributions installed on the systems
+ that popcorn submissions are received from.</p>
-<p>Information about a distribution, including all the submissions
-received for that distribution.</p>
+ <h3 id="show-a-distribution">Show a distribution</h3>
-<code>GET /distro/&lt;distro_name&gt;/&lt;distro_version&gt;</code>
+ <p>Information about a distribution, including all the submissions
+ received for that distribution.</p>
-<h4>Arguments:</h4>
+ <code>GET /distro/&lt;distro_name&gt;/&lt;distro_version&gt;</code>
-<dl class="dl-horizontal">
- <dt>distro_name</dt>
- <dd>Canonical distribution name (e.g. "openSUSE", "SUSE Linux
- Enterprise Server") </dd>
+ <h4>Arguments:</h4>
- <dt>distro_version</dt>
- <dd>Distribution version (e.g. 12.1, 11)
-</dl>
+ <dl class="dl-horizontal">
+ <dt>distro_name</dt>
+ <dd>Canonical distribution name (e.g. "openSUSE", "SUSE Linux
+ Enterprise Server") </dd>
+ <dt>distro_version</dt>
+ <dd>Distribution version (e.g. 12.1, 11)
+ </dl>
+ </div>
+ <div class="span5">
+ <h4>Submissions for each distribution version</h4>
+ <div id="submissions_distrover" style="width: 400px; height: 300px;"></div>
+ </div>
+</div>
<h4>Response</h4>
<pre>
17 popcorn/views.py
View
@@ -180,8 +180,21 @@ def distro(name, version):
@app.route('/distro')
@render(template='distro_doc.html')
def distro_doc():
- """Document the Distro related API functions"""
- pass
+ """Document the Distro related API functions
+
+ Also returns a nested list of [distrovers, number of submissions] pairs.
+
+ """
+ # number of submissions per distribution
+ submissions_distrover = db_session.query(
+ Submission.distro_name + ' ' + Submission.distro_version,
+ func.count(Submission.sub_id)
+ ).group_by(Submission.distro_name, Submission.distro_version).all()
+
+ # transform the list of tuples returned by SQLA into a nested JS array
+ submissions_distrover = json.dumps(submissions_distrover)
+
+ return dict(submissions_distrover=submissions_distrover)
@app.route('/api')
Please sign in to comment.
Something went wrong with that request. Please try again.