new: dev: netloc rangk table

This commit is contained in:
rachmadaniHaryono 2018-04-21 09:38:09 +08:00
parent d4c5451add
commit c9191e7d83
2 changed files with 44 additions and 3 deletions

View File

@ -450,15 +450,16 @@ def view_statistic():
"#ABCDEF", "#DDDDDD", "#ABCABC", "#4169E1",
"#C71585", "#FF4500", "#FEDCBA", "#46BFBD"]
if unique_netloc_len > len(colors):
max_item = len(colors)
max_netloc_item = len(colors)
else:
colors = colors[:unique_netloc_len]
max_item = unique_netloc_len
most_common_netlocs = netloc_counter.most_common(max_item)
max_netloc_item = unique_netloc_len
most_common_netlocs = netloc_counter.most_common(max_netloc_item)
most_common_netlocs = [[val[0], val[1], colors[idx]] for idx, val in enumerate(most_common_netlocs)]
return render_template(
'bukuserver/statistic.html',
most_common_netlocs=most_common_netlocs,
netloc_counter=netloc_counter,
datetime=statistic_datetime,
datetime_text=statistic_datetime.humanize(arrow.now(), granularity='second'),
)

View File

@ -13,6 +13,9 @@
<canvas id="mostCommonChart" width="500" height="500"></canvas>
</div>
<div class="col-md-6">
<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#netlocModal">
View all
</button>
<table class="table">
<tr>
<th>Rank</th>
@ -33,6 +36,43 @@
{% endfor %}
</table>
</div>
<div class="modal fade" id="netlocModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Netloc ranking</h4>
</div>
<div class="modal-body">
<table class="table table-condensed">
<tr>
<th>Rank</th>
<th>Netloc</th>
<th>Number</th>
</tr>
{% for netloc, number in netloc_counter.most_common() %}
{% if number > 1 %}
<tr>
<td>{{loop.index}}</td>
<td>
{% if netloc %}
<form action="{{url_for('search_bookmarks-html')}}" method="GET">
<input id="inputKeywords" name="keywords-0" type="hidden" value="{{netloc}}">
<button type="submit" class="btn btn-default">{{netloc}}</button>
</form>
{% else %}
<span class="btn btn-default" disabled="disabled">(No Netloc)</span>
{% endif %}
</td>
<td>{{number}}</td>
</tr>
{% endif %}
{% endfor %}
</table>
</div>
</div>
</div>
</div>
<script>
var ctx = document.getElementById("mostCommonChart").getContext('2d');
var netlocChart = new Chart(ctx, {