mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-26 15:57:16 +00:00
chg: [crawler stats] add previous month stats by domain type
This commit is contained in:
parent
21642fe9d4
commit
4eb1b01370
3 changed files with 28 additions and 0 deletions
|
@ -263,3 +263,9 @@ def sanitise_daterange(date_from, date_to, separator='', date_type='str'):
|
|||
date_from = date_to
|
||||
date_to = res
|
||||
return date_from, date_to
|
||||
|
||||
def get_previous_month_date():
|
||||
now = datetime.date.today()
|
||||
first = now.replace(day=1)
|
||||
last_month = first - datetime.timedelta(days=1)
|
||||
return last_month.strftime("%Y%m%d")
|
||||
|
|
|
@ -316,6 +316,17 @@ def crawlers_last_domains_month_json():
|
|||
stats = crawlers.get_crawlers_stats_by_month(domain_type)
|
||||
return jsonify(stats)
|
||||
|
||||
@crawler_splash.route('/crawlers/last/domains/month/previous/json')
|
||||
@login_required
|
||||
@login_read_only
|
||||
def crawlers_last_domains_previous_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
|
||||
date = Date.get_previous_month_date()
|
||||
stats = crawlers.get_crawlers_stats_by_month(domain_type, date=date)
|
||||
return jsonify(stats)
|
||||
|
||||
@crawler_splash.route('/crawlers/last/domains/status/month/json')
|
||||
@login_required
|
||||
@login_read_only
|
||||
|
|
|
@ -95,6 +95,10 @@
|
|||
<div id="barchart_type_month"></div>
|
||||
<div class="text-center" id="pie_chart_month"></div>
|
||||
|
||||
<h3>Previous Month Stats:</h3>
|
||||
<div id="barchart_type_month"></div>
|
||||
<div class="text-center" id="barchart_type_previous_month"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -156,6 +160,13 @@ $(document).ready(function(){
|
|||
}
|
||||
);
|
||||
|
||||
$.getJSON("{{ url_for('crawler_splash.crawlers_last_domains_previous_month_json') }}?type={{type}}",
|
||||
function (data) {
|
||||
let div_width = $("#barchart_type_previous_month").width();
|
||||
barchart_stack("barchart_type_previous_month", data, {"width": div_width});
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
function toggle_sidebar(){
|
||||
|
|
Loading…
Reference in a new issue