sort most talked to recievers
This commit is contained in:
parent
148a9f309d
commit
e8ff25eb06
22
main.js
22
main.js
@ -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,
|
||||
@ -56,17 +57,30 @@ fs.readFile('source_data/outbox.json',
|
||||
if (!TemplateVars.outboxStatistics[copyFolk]) {
|
||||
TemplateVars.outboxStatistics[copyFolk] = {
|
||||
name : copyFolk,
|
||||
counter: 0
|
||||
}
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user