function isRecent(page) {
return page.time > DATE_THRESHOLD;
}
function isFinishedProject(page) {
var tags = page.tags || [];
return !tags.includes("wip") && (tags.includes("big project") || tags.includes("small project"));
}
function populateTime(page) {
const match = /end:(\d\d\d\d-\d\d-\d\d)/g.exec(page.description);
const time = new Date(match ? match[1] : page.createdAt);
return {
...page,
time
};
}
function decorateTitle(page) {
return {
...page,
title: "• " + ((page.tags || []).includes("big project") ? "🔥" : "") + page.title
}
}
function showTimeline(data) {
milestones('#timeline')
.mapping({
timestamp: 'time',
text: 'title',
url: 'path'
})
.orientation('vertical')
.aggregateBy('week')
.render(data);
}
async function renderTimeline() {
var rawResponse = await fetch("/graphql", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
credentials: "same-origin",
body: JSON.stringify(GRAPHQL_PAYLOAD),
});
var content = await rawResponse.json();
var timedPages = content.data.pages.list.map(populateTime).map(decorateTitle).filter(isFinishedProject).filter(isRecent);
showTimeline(timedPages);
}
renderTimeline();