mirror of https://github.com/CIRCL/AIL-framework
fix: [crawler] fix monthly crawled domains stats
parent
0d55725e28
commit
e6d70e4f7b
|
@ -306,10 +306,10 @@ def crawlers_last_domains_json():
|
||||||
stats.append(crawlers.get_crawlers_stats_by_day(date, domain_type))
|
stats.append(crawlers.get_crawlers_stats_by_day(date, domain_type))
|
||||||
return jsonify(stats)
|
return jsonify(stats)
|
||||||
|
|
||||||
@crawler_splash.route('/crawlers/last/domains/monthly/json')
|
@crawler_splash.route('/crawlers/last/domains/month/json')
|
||||||
@login_required
|
@login_required
|
||||||
@login_read_only
|
@login_read_only
|
||||||
def crawlers_last_domains_monthly_json():
|
def crawlers_last_domains_month_json():
|
||||||
domain_type = request.args.get('type')
|
domain_type = request.args.get('type')
|
||||||
if domain_type not in crawlers.get_crawler_all_types():
|
if domain_type not in crawlers.get_crawler_all_types():
|
||||||
return jsonify({'error': 'Invalid domain type'}), 400
|
return jsonify({'error': 'Invalid domain type'}), 400
|
||||||
|
|
|
@ -102,6 +102,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h3>Month Stats:</h3>
|
||||||
<div id="barchart_type_month"></div>
|
<div id="barchart_type_month"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -144,14 +145,13 @@ $(document).ready(function(){
|
||||||
$('#date-range-to-input').val(s2);
|
$('#date-range-to-input').val(s2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
chart.stackBarChart = barchart_type_stack("{{ url_for('crawler_splash.crawlers_last_domains_json') }}?type={{type}}", '#barchart_type');
|
||||||
|
chart.stackBarChartMonth = barchart_type_stack("{{ url_for('crawler_splash.crawlers_last_domains_month_json') }}?type={{type}}", '#barchart_type_month');
|
||||||
|
|
||||||
chart.stackBarChart = barchart_type_stack("{{ url_for('crawler_splash.crawlers_last_domains_json') }}?type={{type}}", 'barchart_type');
|
//chart.onResize();
|
||||||
chart.stackBarChartMonth = barchart_type_stack("{{ url_for('crawler_splash.crawlers_last_domains_monthly_json') }}?type={{type}}", 'barchart_type_month');
|
//$(window).on("resize", function() {
|
||||||
|
// chart.onResize();
|
||||||
chart.onResize()
|
//});
|
||||||
$(window).on("resize", function() {
|
|
||||||
chart.onResize();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('[data-toggle="popover"]').popover({
|
$('[data-toggle="popover"]').popover({
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
|
@ -177,30 +177,31 @@ function toggle_sidebar(){
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var margin = {top: 20, right: 90, bottom: 55, left: 0},
|
|
||||||
width = parseInt(d3.select('#' + id).style('width'), 10);
|
|
||||||
width = 1000 - margin.left - margin.right,
|
|
||||||
height = 500 - margin.top - margin.bottom;
|
|
||||||
var x = d3.scaleBand().rangeRound([0, width]).padding(0.1);
|
|
||||||
|
|
||||||
var y = d3.scaleLinear().rangeRound([height, 0]);
|
|
||||||
|
|
||||||
var xAxis = d3.axisBottom(x);
|
|
||||||
|
|
||||||
var yAxis = d3.axisLeft(y);
|
|
||||||
|
|
||||||
var color = d3.scaleOrdinal(d3.schemeSet3);
|
|
||||||
|
|
||||||
var svg = d3.select("#" + id).append("svg")
|
|
||||||
.attr("id", "thesvg")
|
|
||||||
.attr("viewBox", "0 0 "+width+" 500")
|
|
||||||
.attr("width", width + margin.left + margin.right)
|
|
||||||
.attr("height", height + margin.top + margin.bottom)
|
|
||||||
.append("g")
|
|
||||||
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
|
||||||
|
|
||||||
|
|
||||||
function barchart_type_stack(url, id) {
|
function barchart_type_stack(url, svg_id) {
|
||||||
|
|
||||||
|
var margin = {top: 20, right: 90, bottom: 55, left: 0},
|
||||||
|
width = parseInt(d3.select(svg_id).style('width'), 10);
|
||||||
|
width = 1000 - margin.left - margin.right,
|
||||||
|
height = 500 - margin.top - margin.bottom;
|
||||||
|
var x = d3.scaleBand().rangeRound([0, width]).padding(0.1);
|
||||||
|
|
||||||
|
var y = d3.scaleLinear().rangeRound([height, 0]);
|
||||||
|
|
||||||
|
var xAxis = d3.axisBottom(x);
|
||||||
|
|
||||||
|
var yAxis = d3.axisLeft(y);
|
||||||
|
|
||||||
|
var color = d3.scaleOrdinal(d3.schemeSet3);
|
||||||
|
|
||||||
|
var svg = d3.select(svg_id).append("svg")
|
||||||
|
.attr("id", "thesvg")
|
||||||
|
.attr("viewBox", "0 0 "+width+" 500")
|
||||||
|
.attr("width", width + margin.left + margin.right)
|
||||||
|
.attr("height", height + margin.top + margin.bottom)
|
||||||
|
.append("g")
|
||||||
|
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
||||||
|
|
||||||
d3.json(url)
|
d3.json(url)
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
|
@ -281,29 +282,29 @@ function barchart_type_stack(url, id) {
|
||||||
drawLegend(varNames);
|
drawLegend(varNames);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawLegend (varNames) {
|
function drawLegend (varNames) {
|
||||||
var legend = svg.selectAll(".legend")
|
var legend = svg.selectAll(".legend")
|
||||||
.data(varNames.slice().reverse())
|
.data(varNames.slice().reverse())
|
||||||
.enter().append("g")
|
.enter().append("g")
|
||||||
.attr("class", "legend")
|
.attr("class", "legend")
|
||||||
.attr("transform", function (d, i) { return "translate(0," + i * 20 + ")"; });
|
.attr("transform", function (d, i) { return "translate(0," + i * 20 + ")"; });
|
||||||
|
|
||||||
legend.append("rect")
|
legend.append("rect")
|
||||||
.attr("x", 943)
|
.attr("x", 943)
|
||||||
.attr("width", 10)
|
.attr("width", 10)
|
||||||
.attr("height", 10)
|
.attr("height", 10)
|
||||||
.style("fill", color)
|
.style("fill", color)
|
||||||
.style("stroke", "grey");
|
.style("stroke", "grey");
|
||||||
|
|
||||||
legend.append("text")
|
legend.append("text")
|
||||||
.attr("class", "svgText")
|
.attr("class", "svgText")
|
||||||
.attr("x", 941)
|
.attr("x", 941)
|
||||||
.attr("y", 6)
|
.attr("y", 6)
|
||||||
.attr("dy", ".35em")
|
.attr("dy", ".35em")
|
||||||
.style("text-anchor", "end")
|
.style("text-anchor", "end")
|
||||||
.text(function (d) { return d; });
|
.text(function (d) { return d; });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removePopovers () {
|
function removePopovers () {
|
||||||
|
|
Loading…
Reference in New Issue