More closely match Mastodon's way of counting posts.
rodzic
7af6a72859
commit
cec967ddd7
|
@ -13,7 +13,7 @@ import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import get
|
|||
<img class="img-thumbnail" width="64" height="64" src="${s.avatar_url}">
|
||||
`:s.avatar&&(userAvatar.innerHTML=`
|
||||
<img class="img-thumbnail" width="64" height="64" src="data:image/jpg;base64,${s.avatar}">
|
||||
`)):(userInfo.remove(),userDescription.remove()),[]),o;s?.outbox?.orderedItems?r=s.outbox.orderedItems:s?.outbox&&(r=s.outbox),i=r.length;let n=[],l={posts:0,replies:0,reblogs:0,total:0};if(i){const m=Math.ceil(Math.pow(r.length,.1));let s=0;o=r[0],r.forEach(t=>{let o=!1;if([...t.to,...t.cc].forEach(e=>{e.endsWith("/followers")&&(o=!0)}),o){if(s++,10<=r.length&&s<=m){const t=r[Math.pow(10,s)];var a=t.id.replace("/activity","");let e=!1;t.object.id||(e=!0),a={label:[Math.pow(10,s).toLocaleString()+"th post"],url:a,isBoost:e},n.push(a)}l.total++,"Create"===t.type?t.object.inReplyTo?l.replies++:l.posts++:l.reblogs++}})}var i={weekday:"long",year:"numeric",month:"long",day:"numeric"};s.actor&&(d=moment(s.actor.published),d=moment().diff(d,"days"),t+=`
|
||||
`)):(userInfo.remove(),userDescription.remove()),[]),o;s?.outbox?.orderedItems?r=s.outbox.orderedItems:s?.outbox&&(r=s.outbox),i=r.length;let n=[],l={posts:0,replies:0,reblogs:0,total:0};if(i){const c=Math.ceil(Math.pow(r.length,.1));let s=0;o=r[0],r.forEach(t=>{let o=!1;if([...t.to,...t.cc].forEach(e=>{e.endsWith("/followers")&&(o=!0)}),o){if(s++,10<=r.length&&s<=c){const t=r[Math.pow(10,s)];var a=t.id.replace("/activity","");let e=!1;t.object.id||(e=!0),a={label:[Math.pow(10,s).toLocaleString()+"th post"],url:a,isBoost:e},n.push(a)}if(l.total++,"Create"===t.type)t.object.inReplyTo?l.replies++:l.posts++;else try{t.id&&t.object&&t.id.split("/users/")[0]===t.object.split("/users/")[0]?(console.log(t),l.posts++,l.total++):l.reblogs++}catch(e){}}})}var i={weekday:"long",year:"numeric",month:"long",day:"numeric"};s.actor&&(d=moment(s.actor.published),d=moment().diff(d,"days"),t+=`
|
||||
<p>
|
||||
You created your account on <strong>${new Date(s.actor.published).toLocaleDateString(void 0,i)}</strong>, which is <strong>${d.toLocaleString()} day(s) ago</strong>. Since then, you posted <strong>${l.total.toLocaleString()} times</strong>, or about ${Math.round(l.total/d).toLocaleString()} time(s) a day on average.
|
||||
</p>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -112,40 +112,33 @@ const handleUpload = () => {
|
|||
let isSemiPublic = false;
|
||||
const recipients = [...post.to, ...post.cc];
|
||||
|
||||
recipients.forEach(recipient => {
|
||||
if (recipient.endsWith("/followers")){
|
||||
recipients.forEach((recipient) => {
|
||||
if (recipient.endsWith("/followers")) {
|
||||
isSemiPublic = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (isSemiPublic) {
|
||||
index++;
|
||||
if (posts.length >= 10 && index <= maxRoot) {
|
||||
const post = posts[Math.pow(10, index)];
|
||||
const url = post.id.replace("/activity", "");
|
||||
|
||||
|
||||
let milestone = {};
|
||||
let isBoost = false;
|
||||
|
||||
|
||||
if (!post.object.id) {
|
||||
isBoost = true;
|
||||
}
|
||||
|
||||
|
||||
milestone = {
|
||||
label: [`${Math.pow(10, index).toLocaleString()}th post`],
|
||||
url,
|
||||
isBoost,
|
||||
};
|
||||
|
||||
|
||||
milestones.push(milestone);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
counter.total++;
|
||||
if (post.type === "Create") {
|
||||
if (post.object.inReplyTo) {
|
||||
|
@ -154,7 +147,22 @@ const handleUpload = () => {
|
|||
counter.posts++;
|
||||
}
|
||||
} else {
|
||||
counter.reblogs++;
|
||||
try {
|
||||
if (
|
||||
post.id &&
|
||||
post.object &&
|
||||
post.id.split("/users/")[0] ===
|
||||
post.object.split("/users/")[0]
|
||||
) {
|
||||
console.log(post);
|
||||
counter.posts++;
|
||||
counter.total++;
|
||||
} else {
|
||||
counter.reblogs++;
|
||||
}
|
||||
} catch (err) {
|
||||
/*noop*/
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// console.log(post.id.replace("users/", "@").replace("statuses/", "").replace("/activity", ""), recipients);
|
||||
|
@ -193,13 +201,6 @@ const handleUpload = () => {
|
|||
`;
|
||||
}
|
||||
|
||||
/*
|
||||
counter = {
|
||||
posts: 0,
|
||||
replies: 0,
|
||||
reblogs: 0,
|
||||
*/
|
||||
|
||||
if (counter.reblogs > 0 || counter.replies > 0) {
|
||||
userDataBreakdownHTML += `
|
||||
<p>
|
||||
|
|
Ładowanie…
Reference in New Issue