euscanwww: tweak the new handler code
Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
This commit is contained in:
parent
a723d30a33
commit
c6a0c29401
@ -109,6 +109,15 @@ class PackageMixin(object):
|
|||||||
)
|
)
|
||||||
return packages.filter(version__overlay=overlay).distinct()
|
return packages.filter(version__overlay=overlay).distinct()
|
||||||
|
|
||||||
|
def for_handler(self, handler):
|
||||||
|
"""
|
||||||
|
Returns packages that belong to the given handler
|
||||||
|
"""
|
||||||
|
packages = self.values(
|
||||||
|
'id', 'name', 'category', 'n_versions', 'n_packaged', 'n_overlay'
|
||||||
|
)
|
||||||
|
return packages.filter(version__handler=handler,
|
||||||
|
version__overlay="").distinct()
|
||||||
|
|
||||||
class PackageQuerySet(models.query.QuerySet, PackageMixin):
|
class PackageQuerySet(models.query.QuerySet, PackageMixin):
|
||||||
pass
|
pass
|
||||||
|
@ -147,7 +147,7 @@ class Version(models.Model):
|
|||||||
alive = models.BooleanField(default=True, db_index=True)
|
alive = models.BooleanField(default=True, db_index=True)
|
||||||
|
|
||||||
vtype = models.CharField(max_length=128, blank=True)
|
vtype = models.CharField(max_length=128, blank=True)
|
||||||
handler = models.CharField(max_length=128, blank=True)
|
handler = models.CharField(max_length=128, blank=True, db_index=True)
|
||||||
confidence = models.IntegerField(default=0)
|
confidence = models.IntegerField(default=0)
|
||||||
|
|
||||||
ebuild_path = models.CharField(blank=True, max_length=256)
|
ebuild_path = models.CharField(blank=True, max_length=256)
|
||||||
|
@ -2,18 +2,56 @@
|
|||||||
|
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}css/table.css" media="screen" title="Normal" />
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script type="text/javascript" language="javascript" src="{{STATIC_URL}}js/jquery.js"></script>
|
||||||
|
<script type="text/javascript" language="javascript" src="{{STATIC_URL}}js/jquery.dataTables.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#table').dataTable( {
|
||||||
|
"bPaginate": false,
|
||||||
|
"bInfo": false,
|
||||||
|
"bStateSave": true,
|
||||||
|
"sCookiePrefix": "datatables_"
|
||||||
|
} );
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Statistics</h2>
|
<h2>Statistics</h2>
|
||||||
|
|
||||||
<hr>
|
<hr />
|
||||||
|
|
||||||
|
<h3>Current statistics</h3>
|
||||||
|
<img alt="pie versions" src="{% url "chart" 'pie-versions' %}" />
|
||||||
|
<img alt="pie packages" src="{% url "chart" 'pie-packages' %}" />
|
||||||
|
|
||||||
|
<h3>All time statistics</h3>
|
||||||
|
|
||||||
|
<img alt="packages weekly" src="{% url "chart" 'packages-weekly' %}" />
|
||||||
|
<img alt="packages monthly" src="{% url "chart" 'packages-monthly' %}" />
|
||||||
|
|
||||||
|
<img alt="versions weekly" src="{% url "chart" 'versions-weekly' %}" />
|
||||||
|
<img alt="versions monthly" src="{% url "chart" 'versions-monthly' %}" />
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
<h3>Handlers</h3>
|
<h3>Handlers</h3>
|
||||||
<table class="table">
|
<table id="table" class="display">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th>Handler</th>
|
||||||
<th># of found versions</th>
|
<th># of found versions</th>
|
||||||
<th>average confidence</th>
|
<th>Average confidence</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -31,18 +69,4 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h3>Current statistics</h3>
|
|
||||||
<img alt="pie versions" src="{% url "chart" 'pie-versions' %}" />
|
|
||||||
<img alt="pie packages" src="{% url "chart" 'pie-packages' %}" />
|
|
||||||
|
|
||||||
<h3>All time statistics</h3>
|
|
||||||
|
|
||||||
<img alt="packages weekly" src="{% url "chart" 'packages-weekly' %}" />
|
|
||||||
<img alt="packages monthly" src="{% url "chart" 'packages-monthly' %}" />
|
|
||||||
|
|
||||||
<img alt="versions weekly" src="{% url "chart" 'versions-weekly' %}" />
|
|
||||||
<img alt="versions monthly" src="{% url "chart" 'versions-monthly' %}" />
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -88,7 +88,7 @@ urlpatterns = patterns('djeuscan.views',
|
|||||||
url(r'^about/feeds$', 'feeds', name="feeds"),
|
url(r'^about/feeds$', 'feeds', name="feeds"),
|
||||||
url(r'^about/config$', 'config', name="config"),
|
url(r'^about/config$', 'config', name="config"),
|
||||||
url(r'^statistics/$', 'statistics', name="statistics"),
|
url(r'^statistics/$', 'statistics', name="statistics"),
|
||||||
url(r'^statistics/handlers/(?P<handler>\w+)/$', 'statistics_handler',
|
url(r'^statistics/handlers/(?P<handler>[^/]+)/$', 'statistics_handler',
|
||||||
name="statistics_handler"),
|
name="statistics_handler"),
|
||||||
url(r'^statistics/charts/(?P<chart>[\w\-]+).png$', 'chart', name="chart"),
|
url(r'^statistics/charts/(?P<chart>[\w\-]+).png$', 'chart', name="chart"),
|
||||||
url(r'^world/$', 'world', name="world"),
|
url(r'^world/$', 'world', name="world"),
|
||||||
|
@ -380,25 +380,29 @@ def config(request):
|
|||||||
|
|
||||||
@render_to("euscan/statistics.html")
|
@render_to("euscan/statistics.html")
|
||||||
def statistics(request):
|
def statistics(request):
|
||||||
handlers = (
|
# Didn't found a way to do:
|
||||||
Version.objects.values("handler", "confidence")
|
# SELECT COUNT(*), AVG(confidence) FROM Versions
|
||||||
|
# GROUP BY handler
|
||||||
|
handlers = ( Version.objects.values("handler")
|
||||||
.filter(overlay="")
|
.filter(overlay="")
|
||||||
.annotate(n=models.Count("handler"),
|
.annotate(n=models.Count("handler"))
|
||||||
avg_conf=models.Avg("confidence"))
|
|
||||||
.order_by("-n")
|
|
||||||
)
|
)
|
||||||
|
for i in xrange(len(handlers)):
|
||||||
|
handler_id = handlers[i]['handler']
|
||||||
|
avg = ( Version.objects.filter(handler=handler_id)
|
||||||
|
.aggregate(avg=models.Avg("confidence"))
|
||||||
|
)
|
||||||
|
if not handler_id:
|
||||||
|
handlers[i]['handler'] = "None"
|
||||||
|
handlers[i]['avg_conf'] = avg['avg'] if 'avg' in avg else 0
|
||||||
return {"handlers": handlers}
|
return {"handlers": handlers}
|
||||||
|
|
||||||
|
|
||||||
@render_to("euscan/statistics_handler.html")
|
@render_to("euscan/statistics_handler.html")
|
||||||
def statistics_handler(request, handler):
|
def statistics_handler(request, handler):
|
||||||
package_ids = [
|
if handler == "None":
|
||||||
elem["package"] for elem in
|
handler = ""
|
||||||
Version.objects.filter(handler=handler)
|
packages = Package.objects.for_handler(handler)
|
||||||
.values("package")
|
|
||||||
.distinct()
|
|
||||||
]
|
|
||||||
packages = Package.objects.filter(pk__in=package_ids)
|
|
||||||
return {"handler": handler, "packages": packages}
|
return {"handler": handler, "packages": packages}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user