mirror of https://github.com/CIRCL/AIL-framework
chg: [domains] add crawler status stats by domain type pie chart
parent
142ac83472
commit
d5e830c591
|
@ -931,6 +931,13 @@ def get_crawlers_stats_by_month(domain_type, date=None):
|
||||||
stats.append(get_crawlers_stats_by_day(date, domain_type))
|
stats.append(get_crawlers_stats_by_day(date, domain_type))
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
def get_crawlers_stats_up_down_by_month(domain_type, date=None):
|
||||||
|
stats = {'down': 0, 'up': 0}
|
||||||
|
for date in Date.get_month_dates(date=date):
|
||||||
|
day = get_crawlers_stats_by_day(date, domain_type)
|
||||||
|
stats['down'] += day.get('down', 0)
|
||||||
|
stats['up'] += day.get('up', 0)
|
||||||
|
return stats
|
||||||
|
|
||||||
def get_crawlers_stats(domain_type=None):
|
def get_crawlers_stats(domain_type=None):
|
||||||
stats = {}
|
stats = {}
|
||||||
|
|
|
@ -316,6 +316,19 @@ def crawlers_last_domains_month_json():
|
||||||
stats = crawlers.get_crawlers_stats_by_month(domain_type)
|
stats = crawlers.get_crawlers_stats_by_month(domain_type)
|
||||||
return jsonify(stats)
|
return jsonify(stats)
|
||||||
|
|
||||||
|
@crawler_splash.route('/crawlers/last/domains/status/month/json')
|
||||||
|
@login_required
|
||||||
|
@login_read_only
|
||||||
|
def crawlers_last_domains_status_month_json():
|
||||||
|
domain_type = request.args.get('type')
|
||||||
|
if domain_type not in crawlers.get_crawler_all_types():
|
||||||
|
return jsonify({'error': 'Invalid domain type'}), 400
|
||||||
|
stats = crawlers.get_crawlers_stats_up_down_by_month(domain_type)
|
||||||
|
data = []
|
||||||
|
for key in stats:
|
||||||
|
data.append({'name': key, 'value': stats[key]})
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
#### Domains ####
|
#### Domains ####
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<script src="{{ url_for('static', filename='js/jquery.daterangepicker.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/jquery.daterangepicker.min.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/d3.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/d3.min.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/d3/barchart_stack.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/d3/barchart_stack.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/d3/pie_chart.js') }}"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.domain_name {
|
.domain_name {
|
||||||
|
@ -91,8 +92,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Month Stats:</h3>
|
<h3>Month Stats:</h3>
|
||||||
<div id="pie_chart_month"></div>
|
|
||||||
<div id="barchart_type_month"></div>
|
<div id="barchart_type_month"></div>
|
||||||
|
<div class="text-center" id="pie_chart_month"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -142,6 +143,12 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$.getJSON("{{ url_for('crawler_splash.crawlers_last_domains_status_month_json') }}?type={{type}}",
|
||||||
|
function (data) {
|
||||||
|
pie_chart("pie_chart_month", data, {});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$.getJSON("{{ url_for('crawler_splash.crawlers_last_domains_month_json') }}?type={{type}}",
|
$.getJSON("{{ url_for('crawler_splash.crawlers_last_domains_month_json') }}?type={{type}}",
|
||||||
function (data) {
|
function (data) {
|
||||||
let div_width = $("#barchart_type_month").width();
|
let div_width = $("#barchart_type_month").width();
|
||||||
|
|
Loading…
Reference in New Issue