Commit e8ff25eb authored by ty kayn's avatar ty kayn

sort most talked to recievers

parent 148a9f30
......@@ -8,7 +8,8 @@ const app = express();
var fs = require('fs');
var listenPort = 8088;
var jsonParsedLikes, jsonParsedOutbox;
const min_length = 1050; // filter only long toots
// const min_length = 1050; // filter only long toots
const min_length = 1; // filter only long toots
const TemplateVars = {
pageTitle : 'Mastodon export converter to HTML',
likes : jsonParsedLikes,
......@@ -53,20 +54,33 @@ fs.readFile('source_data/outbox.json',
minchartoots.forEach(elem => {
if (elem['object'].cc) {
elem['object'].cc.forEach(copyFolk => {
if(!TemplateVars.outboxStatistics[copyFolk]){
if (!TemplateVars.outboxStatistics[copyFolk]) {
TemplateVars.outboxStatistics[copyFolk] = {
name : copyFolk,
counter: 0
}
name : copyFolk,
counter: 0,
};
}
TemplateVars.outboxStatistics[copyFolk].counter += 1;
});
}
});
const statKeys = Object.keys(TemplateVars.outboxStatistics);
const arrayToSort = [];
statKeys.forEach(elem => {
arrayToSort.push(
TemplateVars.outboxStatistics[elem],
);
});
arrayToSort.sort( (a,b)=>{
return b.counter - a.counter
})
console.log('arrayToSort', arrayToSort)
TemplateVars.outboxStatistics = arrayToSort;
console.log('TemplateVars.outbox.length', TemplateVars.outbox.length, TemplateVars.outbox[5]['object'].content.length);
TemplateVars.example = example;
console.log('example', example);
// console.log('example', example);
});
app.use(express.static('public'));
app.set('view engine', 'pug');
......
......@@ -10,7 +10,8 @@ html(lang="en")
fieldset.stats
h3 You did sent messages to these people
each someone in outboxStatistics
.name=someone.name
.name
a(href=someone.name)=someone.name
.counter=someone.counter
h2 #{outbox.length} Messages in your outbox. Filtered by a minimal length of #{min_length}
.columns-area__panels__main
......
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