mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-26 15:57:16 +00:00
chg: [domains] add crawler status stats by domain type pie chart
This commit is contained in:
parent
142ac83472
commit
d5e830c591
3 changed files with 28 additions and 1 deletions
|
@ -931,6 +931,13 @@ def get_crawlers_stats_by_month(domain_type, date=None):
|
|||
stats.append(get_crawlers_stats_by_day(date, domain_type))
|
||||
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):
|
||||
stats = {}
|
||||
|
|
|
@ -316,6 +316,19 @@ def crawlers_last_domains_month_json():
|
|||
stats = crawlers.get_crawlers_stats_by_month(domain_type)
|
||||
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 ####
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<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/barchart_stack.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/d3/pie_chart.js') }}"></script>
|
||||
|
||||
<style>
|
||||
.domain_name {
|
||||
|
@ -91,8 +92,8 @@
|
|||
</div>
|
||||
|
||||
<h3>Month Stats:</h3>
|
||||
<div id="pie_chart_month"></div>
|
||||
<div id="barchart_type_month"></div>
|
||||
<div class="text-center" id="pie_chart_month"></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}}",
|
||||
function (data) {
|
||||
let div_width = $("#barchart_type_month").width();
|
||||
|
|
Loading…
Reference in a new issue