Now I can export data from reports: posts, new users, etc…
It’s cool! But it might be super-cool if Discourse shows a total amount by range selected since I can simply aggregate such data, for example new users/posts/topics by month
Doing this using excel isn’t really handy
2 Likes
Do you have any experience writing browser extensions?
I threw this together for Firefox but I imagine a Chrome extension would be similar
self.port.on('viewing_admin_reports_visits', function () {
"use strict";
var visit_cells = document.querySelectorAll("table[class~='report'] tbody tr td");
var h3_heading = document.querySelector("div#main-outlet h3");
var visit_cells_len = visit_cells.length;
var high_visit = 0;
var high_visit_cell_num = 0;
var total_count = 0;
for (var i = 0; i < visit_cells_len; i++) {
if (/[\d]{4}-[\d]{2}-[\d]{2}/.test(visit_cells[i].textContent)) {
var ymd_date = new Date(visit_cells[i].textContent);
if ( (ymd_date.getUTCDay() == 6) || (ymd_date.getUTCDay() == 0) ) {
visit_cells[i].parentNode.setAttribute('style', "background-color: #efefff");
}
}
if (/\s[\d]+\s/.test(visit_cells[i].textContent)) {
total_count += parseInt(visit_cells[i].textContent);
if (parseInt(visit_cells[i].textContent) > high_visit) {
high_visit = parseInt(visit_cells[i].textContent);
high_visit_cell_num = i;
}
}
}
visit_cells[high_visit_cell_num].setAttribute('style', "font-weight: bold; font-size: 1.2em");
var avg_span = document.createElement('span');
avg_span.textContent = " - average " + Math.round(total_count / (visit_cells_len / 2) ) + " per day";
h3_heading.appendChild(avg_span);
});
mmh I could try thanks…