Skip to content

Shows a table with all open project and a emoji score how long these projects are already open

List all open projects with a emoji age indicator

Basic

TABLE "😡" * (date(now) - date(started)).weeks AS "Score"
FROM "10 Example Data/projects"
WHERE status != "finished"

Variants

Use different emojis for certain timespans

const projects = dv.pages('"10 Example Data/projects"')
    .where(p => p.status !== undefined && p.status != "finished")
    .mutate(p => {
        p.age = p.started && p.started instanceof dv.luxon.DateTime ? dv.luxon.Duration.fromMillis(Date.now() - p.started.toMillis()) : null
        p.emojiAgeScore = getEmojiScore(p)
    })

dv.table(["Score", "Project", "Started", "Age"], projects.map(p => [p.emojiAgeScore, p.file.link, p.started, p.age ? p.age.toFormat("y'y' M'm' w'w'") : 'N/A']))

function getEmojiScore(p) {
    if (!p.age || !(p.age instanceof dv.luxon.Duration)) {
        return ""
    }

    const age = p.age.shiftTo('months').toObject()
    let score = "";

    score += addEmojis("👿", age.months / 6)
    score += addEmojis("😡", (age.months % 6) / 3)
    score += addEmojis("😒", (age.months % 6 % 3))

    return score;
}

function addEmojis(emoji, max) {
    let emojis = "";
    for (let i = 1; i < Math.floor(max); i++) emojis += emoji;
    return emojis;
}