tangled
alpha
login
or
join now
zzstoatzz.io
/
music-atmosphere-feed
0
fork
atom
bsky feeds about music
music-atmosphere-feed.plyr.fm/
bsky
feed
zig
0
fork
atom
overview
issues
pulls
pipelines
dashboard: sort platforms by percentage descending
zzstoatzz.io
2 months ago
732eb398
ef853b05
1/1
ci.yml
success
14s
+8
-2
1 changed file
expand all
collapse all
unified
split
src
server
dashboard.zig
+8
-2
src/server/dashboard.zig
···
179
179
const total = platforms.soundcloud + platforms.bandcamp + platforms.spotify + platforms.plyr;
180
180
181
181
if (total > 0) {
182
182
-
// helper to format percentage - shows "<1%" for non-zero values that round to 0
183
182
const PlatformData = struct { name: []const u8, count: u64, color: []const u8 };
184
184
-
const platform_list = [_]PlatformData{
183
183
+
var platform_list = [_]PlatformData{
185
184
.{ .name = "soundcloud", .count = platforms.soundcloud, .color = "#ff5500" },
186
185
.{ .name = "bandcamp", .count = platforms.bandcamp, .color = "#1da0c3" },
187
186
.{ .name = "spotify", .count = platforms.spotify, .color = "#1db954" },
188
187
.{ .name = "plyr.fm", .count = platforms.plyr, .color = "#7c3aed" },
189
188
};
189
189
+
190
190
+
// sort by count descending
191
191
+
std.mem.sort(PlatformData, &platform_list, {}, struct {
192
192
+
fn cmp(_: void, a: PlatformData, b: PlatformData) bool {
193
193
+
return a.count > b.count;
194
194
+
}
195
195
+
}.cmp);
190
196
191
197
for (platform_list) |p| {
192
198
const pct: f64 = @as(f64, @floatFromInt(p.count)) / @as(f64, @floatFromInt(total)) * 100.0;