Commit 253b9775 authored by tykayn's avatar tykayn

:style: add hashtag occurences stats

parent 4ec80018
......@@ -37,24 +37,47 @@ class Conversion {
}
makeStatsForToots(tootArray){
let stats = {};
let stats = { recievers: {},
hashtags : {}};
// make statistics on who do we talk to, based on the cc field
tootArray.forEach(elem => {
// stats on hashtags
if (elem['object'].tag) {
elem['object'].tag.forEach(tag => {
if(tag.type === 'Hashtag'){
if(!stats.hashtags[tag.name]){
stats.hashtags[tag.name] = {
name : tag.name,
counter : 0,
}
}
stats.hashtags[tag.name].counter++;
}
})
}
// stats on recievers of toots
if (elem['object'].cc) {
elem['object'].cc.forEach(copyFolk => {
if (!stats[copyFolk]) {
stats[copyFolk] = {
if (!stats.recievers[copyFolk]) {
stats.recievers[copyFolk] = {
name : copyFolk,
counter: 0,
counterContentLength: 0,
};
}
stats[copyFolk].counter += 1;
stats[copyFolk].counterContentLength += elem['object'].content.length;
stats.recievers[copyFolk].counter++;
stats.recievers[copyFolk].counterContentLength += elem['object'].content.length;
});
}
});
return this.sortTootsByLength(stats);
console.log('stats.hashtags', stats.hashtags);
stats = {
recievers : this.sortTootsByLength(stats.recievers),
hashtags : this.sortTootsByLength(stats.hashtags),
};
return stats ;
}
sortTootsByLength(stats){
......
......@@ -10,7 +10,7 @@ var fs = require('fs');
var listenPort = 8088;
var jsonParsedLikes, jsonParsedOutbox;
// const min_length = 1050; // filter only long toots
const min_length = 1; // filter only long toots
const min_length = 300; // filter only long toots
const max_toots = 500; // filter only long toots
const filterBiggerTottsBeforeSlicing = false; // filter only long toots
const TemplateVars = {
......@@ -47,12 +47,10 @@ fs.readFile('source_data/outbox.json',
console.log('min_chars', min_length);
console.log('toots min char corresponding', minchartoots.length);
TemplateVars.outbox = minchartoots;
TemplateVars.outboxStatistics = masto_converter.conversion.makeStatsForToots(minchartoots);
const example = TemplateVars.outbox[10]['object'];
const example = TemplateVars.outbox[1]['object'];
TemplateVars.example = example;
console.log('example', example);
fs.writeFile('output/statistics.json', JSON.stringify(TemplateVars.outboxStatistics), errfileHandler );
});
......
......@@ -7,22 +7,37 @@ html(lang="en")
body
h1=pageTitle
h2 Statistics
fieldset.stats
h3 You did sent messages to these people
fieldset.stats.stats-hashtags
h3 You used these HashTags
table
thead
tr
th= "hashtag"
th= "occurences"
tbody
each hashtag in outboxStatistics.hashtags
tr
td.name
a(href=hashtag.name)=hashtag.name
td.counter=hashtag.counter
td.counter=hashtag.counterContentLength
fieldset.stats.stats-recievers
h3 You sent messages to these people
table
thead
tr
th= "name"
th= "toots to"
th= "times"
th= "toots lengh sum"
tbody
each someone in outboxStatistics
each someone in outboxStatistics.recievers
tr
td.name
a(href=someone.name)=someone.name
td.counter=someone.counter
td.counter=someone.counterContentLength
h2 #{outbox.length} of Messages #{outboxTotalLength} in your outbox.First #{max_toots} toots, filtered by a minimal length of #{min_length} characters of content.
.columns-area__panels__main
div.column
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment