Skip to content

Commit 6df0018

Browse files
committed
Slightly nicer formatting
1 parent 8cad2b0 commit 6df0018

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/packages/web/page.gleam

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,36 @@ pub fn packages_list(
2424
}
2525

2626
pub fn internet_points(stats: storage.InternetPoints) -> String {
27-
let count_list = fn(rows) {
28-
rows
29-
|> list.take(50)
30-
|> list.map(fn(row) {
31-
let #(name, count) = row
32-
html.li([], [html.text(name <> ": " <> int.to_string(count))])
33-
})
34-
|> html.ol([], _)
27+
let count_table = fn(rows) {
28+
let rows =
29+
rows
30+
|> list.take(50)
31+
|> list.index_map(fn(row, index) {
32+
let #(name, count) = row
33+
let count =
34+
int.to_string(count)
35+
|> string.to_graphemes
36+
|> list.reverse
37+
|> list.sized_chunk(3)
38+
|> list.intersperse([","])
39+
|> list.flatten
40+
|> list.reverse
41+
|> string.concat
42+
html.tr([], [
43+
html.td([], [html.text(int.to_string(index + 1) <> ".")]),
44+
html.td([], [html.text(name)]),
45+
html.td([], [html.text(count)]),
46+
])
47+
})
48+
49+
html.table([], rows)
3550
}
3651

3752
html.div([], [
3853
html.h2([], [html.text("Package owners total downloads")]),
39-
count_list(stats.owner_download_counts),
54+
count_table(stats.owner_download_counts),
4055
html.h2([], [html.text("Package owners number of packages")]),
41-
count_list(stats.owner_package_counts),
56+
count_table(stats.owner_package_counts),
4257
html.script([attribute.src("https://cdn.plot.ly/plotly-2.30.0.min.js")], ""),
4358
line_chart("Package count", stats.package_counts),
4459
line_chart("Release count", stats.release_counts),

0 commit comments

Comments
 (0)