Overview
Comment:feat(music/render.tcl): group songs by artist
Timelines: family | ancestors | grouped-songs
Files: files | file ages | folders
SHA3-256: 45666ea716d31a50abb3f902275b6a52186e1a3e404b5983ce7bb99ea19e9a01
User & Date: dbohdan on 2020-09-03 17:39:32
Other Links: branch diff | manifest | tags
Context
2020-09-03
17:39
feat(music/render.tcl): group songs by artist Leaf check-in: 45666ea716 user: dbohdan tags: grouped-songs
15:22
fix(music/music.sql): remove trailing period Leaf check-in: 07c0c8617f user: dbohdan tags: trunk
Changes

Modified music/render.tcl from [17282efe99] to [9d073c4f10].

40
41
42
43
44
45
46
47





48
49
50


51

52
53
54
55
56
57
58
..
66
67
68
69
70
71
72
73



74











75
76
77
78
79
80
81
82
83
    db eval {
        SELECT
            categories.name AS category,
            artists.artist,
            songs.title,
            songs.url,
            notes.content AS note,
            tag_list





        FROM songs
        JOIN (
            SELECT DISTINCT artist


            FROM songs

        ) AS artists
        ON songs.artist = artists.artist
        JOIN categories
        ON categories.category_id = songs.category_id
        LEFT JOIN notes
        ON notes.song_id = songs.song_id
        LEFT JOIN (
................................................................................
            artists.artist COLLATE SLUG,
            songs.title;
    } row {
        set class [expr {
            {no-embed} in $row(tag_list) ? {} : {embed}
        }]

        set entry [list \



            "### [entities $row(artist)] — [entities $row(title)]" \











            [a $row(url) $class] \
        ]
        if {$row(note) ne {}} { lappend entry {} $row(note) }

        dict lappend cats $row(category) [join $entry \n]
    }

    puts "# Music links\n\nListen to some music I like.\n"
    puts {## Contents}







|
>
>
>
>
>


|
>
>

>







 







|
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
|
|







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    db eval {
        SELECT
            categories.name AS category,
            artists.artist,
            songs.title,
            songs.url,
            notes.content AS note,
            tag_list,
            row_number() OVER (
                PARTITION BY artists.artist
                RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
            ) AS song_number,
            artists.song_count
        FROM songs
        JOIN (
            SELECT
                artist,
                count(artist) AS song_count
            FROM songs
            GROUP BY artist
        ) AS artists
        ON songs.artist = artists.artist
        JOIN categories
        ON categories.category_id = songs.category_id
        LEFT JOIN notes
        ON notes.song_id = songs.song_id
        LEFT JOIN (
................................................................................
            artists.artist COLLATE SLUG,
            songs.title;
    } row {
        set class [expr {
            {no-embed} in $row(tag_list) ? {} : {embed}
        }]

        set entry {}

        if {$row(song_count) == 1} {
            lappend entry \
                "### [entities $row(artist)] — [entities $row(title)]"
        } else {
            # More than one song by artists; make a group.
            set entry {}

            if {$row(song_number) == 1} {
                lappend entry "### [entities $row(artist)]"
            }

            lappend entry "#### [entities $row(title)]"
        }

        lappend entry [a $row(url) $class]

        if {$row(note) ne {}} { lappend entry {} $row(note) }

        dict lappend cats $row(category) [join $entry \n]
    }

    puts "# Music links\n\nListen to some music I like.\n"
    puts {## Contents}