remove commit activity graph

Delete charts.ml and all associated code: - Remove 30-day frequency computation from summary handler - Remove Charts.commit_frequency call from summary view - Remove Commit.since resolver (no longer used) - Remove chart-container and summary-layout CSS The summary page now shows only the README panel.

Commit
8e221cad1fbbcd1da93f3c0f72d24453b332f303
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/charts.ml
index a138478a..00000000 100644..000000
@@ -1,135 +0,0 @@
1 Removed: (* -*- mode: tuareg; -*- *)
2 Removed:
3 Removed: (** Non-interactive SVG chart generation for embedding in HTML pages. *)
4 Removed:
5 Removed: open Dream_html
6 Removed:
7 Removed: let rect = std_tag "rect"
8 Removed: let text_ = std_tag "text"
9 Removed: let g = std_tag "g"
10 Removed: let line = std_tag "line"
11 Removed: let x = string_attr "x"
12 Removed: let y = string_attr "y"
13 Removed: let width_ = string_attr "width"
14 Removed: let height_ = string_attr "height"
15 Removed: let rx = string_attr "rx"
16 Removed: let x1 = string_attr "x1"
17 Removed: let y1 = string_attr "y1"
18 Removed: let x2 = string_attr "x2"
19 Removed: let y2 = string_attr "y2"
20 Removed: let text_anchor = string_attr "text-anchor"
21 Removed: let font_size = string_attr "font-size"
22 Removed:
23 Removed: (* SVG attribute values are strings, so every computed coordinate has to be
24 Removed: converted. Fractional coordinates are rounded to one decimal: sub-pixel
25 Removed: precision beyond that is invisible and only inflates the markup. *)
26 Removed: let svg_int = string_of_int
27 Removed: let svg_float value = Printf.sprintf "%.1f" value
28 Removed:
29 Removed: (** Render a bar chart of daily commit frequency.
30 Removed:
31 Removed: [values] is a list of [(label, count)] pairs representing consecutive days.
32 Removed: The chart auto-scales vertically to the maximum count. *)
33 Removed: let commit_frequency ~chart_width ~chart_height values =
34 Removed: let n = List.length values in
35 Removed: if n = 0 then HTML.null []
36 Removed: else
37 Removed: let max_count =
38 Removed: List.fold_left (fun acc (_, count) -> max acc count) 0 values
39 Removed: in
40 Removed: let max_count = max max_count 1 in
41 Removed: let padding_top = 20 in
42 Removed: let padding_bottom = 30 in
43 Removed: let padding_left = 30 in
44 Removed: let padding_right = 10 in
45 Removed: let plot_width = chart_width - padding_left - padding_right in
46 Removed: let plot_height = chart_height - padding_top - padding_bottom in
47 Removed: let bar_width = float_of_int plot_width /. float_of_int n in
48 Removed: let gap = bar_width *. 0.2 in
49 Removed: let bar_actual = bar_width -. gap in
50 Removed: (* Y-axis gridlines *)
51 Removed: let grid_lines =
52 Removed: let steps = min 4 max_count in
53 Removed: List.init (steps + 1) (fun i ->
54 Removed: let value = max_count * i / steps in
55 Removed: let y_pos =
56 Removed: padding_top + plot_height - (plot_height * value / max_count)
57 Removed: in
58 Removed: [
59 Removed: line
60 Removed: [
61 Removed: x1 "%s" (svg_int padding_left);
62 Removed: y1 "%s" (svg_int y_pos);
63 Removed: x2 "%s" (svg_int (chart_width - padding_right));
64 Removed: y2 "%s" (svg_int y_pos);
65 Removed: SVG.stroke "#333";
66 Removed: SVG.stroke_width "1";
67 Removed: ]
68 Removed: [];
69 Removed: text_
70 Removed: [
71 Removed: x "%s" (svg_int (padding_left - 5));
72 Removed: y "%s" (svg_int (y_pos + 4));
73 Removed: text_anchor "end";
74 Removed: font_size "10";
75 Removed: SVG.fill "#888";
76 Removed: ]
77 Removed: [ txt "%d" value ];
78 Removed: ])
79 Removed: |> List.concat
80 Removed: in
81 Removed: (* Bars *)
82 Removed: let bars =
83 Removed: List.mapi
84 Removed: (fun i (_, count) ->
85 Removed: let bar_height =
86 Removed: if max_count = 0 then 0 else plot_height * count / max_count
87 Removed: in
88 Removed: let bx =
89 Removed: float_of_int padding_left
90 Removed: +. (float_of_int i *. bar_width)
91 Removed: +. (gap /. 2.0)
92 Removed: in
93 Removed: let by = padding_top + plot_height - bar_height in
94 Removed: rect
95 Removed: [
96 Removed: x "%s" (svg_float bx);
97 Removed: y "%s" (svg_int by);
98 Removed: width_ "%s" (svg_float bar_actual);
99 Removed: height_ "%s" (svg_int bar_height);
100 Removed: rx "2";
101 Removed: SVG.fill "rgb(194, 79, 30)";
102 Removed: ]
103 Removed: [])
104 Removed: values
105 Removed: in
106 Removed: (* X-axis labels — show every 7th day *)
107 Removed: let labels =
108 Removed: List.mapi
109 Removed: (fun i (label, _) ->
110 Removed: if i mod 7 = 0 || i = n - 1 then
111 Removed: let lx =
112 Removed: float_of_int padding_left
113 Removed: +. (float_of_int i *. bar_width)
114 Removed: +. (bar_width /. 2.0)
115 Removed: in
116 Removed: text_
117 Removed: [
118 Removed: x "%s" (svg_float lx);
119 Removed: y "%s" (svg_int (chart_height - 5));
120 Removed: text_anchor "middle";
121 Removed: font_size "10";
122 Removed: SVG.fill "#888";
123 Removed: ]
124 Removed: [ txt "%s" label ]
125 Removed: else HTML.null [])
126 Removed: values
127 Removed: in
128 Removed: SVG.(
129 Removed: svg
130 Removed: [
131 Removed: viewbox ~min_x:0 ~min_y:0 ~width:chart_width ~height:chart_height;
132 Removed: xmlns;
133 Removed: HTML.class_ "chart-commit-frequency";
134 Removed: ]
135 Removed: [ g [] grid_lines; g [] bars; g [] labels ])
lib/handlers.ml
index f43ae818..d3babd84 100644..100644
@@ -150,37 +150,8 @@
150 150 handler repository context id)
151 151
152 152 let summary _config repository context =
153 Removed: let now = Unix.time () in
154 Removed: let days = 30 in
155 Removed: let seconds_per_day = 86400.0 in
156 Removed: let cutoff =
157 Removed: Int64.of_float (now -. (float_of_int days *. seconds_per_day))
158 Removed: in
159 Removed: let* commits = Resolvers.Commit.since repository cutoff in
160 153 let* readme = Resolvers.Repo.readme repository in
161 Removed: (* Group commits by day — build a count for each of the past 30 days *)
162 Removed: let day_of_timestamp ts =
163 Removed: let t = Int64.to_float ts in
164 Removed: let tm = Unix.localtime t in
165 Removed: (tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday)
166 Removed: in
167 Removed: let frequency =
168 Removed: List.init days (fun i ->
169 Removed: let t = now -. (float_of_int (days - 1 - i) *. seconds_per_day) in
170 Removed: let tm = Unix.localtime t in
171 Removed: let key = (tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday) in
172 Removed: let label = Printf.sprintf "%02d/%02d" (tm.tm_mon + 1) tm.tm_mday in
173 Removed: let count =
174 Removed: List.length
175 Removed: (List.filter
176 Removed: (fun (c : Resolvers.Commit.t) ->
177 Removed: let ts, _ = c.author.Git.User.date in
178 Removed: day_of_timestamp ts = key)
179 Removed: commits)
180 Removed: in
181 Removed: (label, count))
182 Removed: in
183 Removed: Views.Repo.summary context ?readme frequency
154 Added: Views.Repo.summary context ?readme ()
184 155
185 156 let commit_matches ?filter_type ?author ?committer
186 157 (commit : Resolvers.Commit.t) =
lib/resolvers.ml
index b054a901..7e092d44 100644..100644
@@ -362,46 +362,6 @@
362 362
363 363 let recent repository count =
364 364 recent_matching repository count (Fun.const true)
365 Removed:
366 Removed: let since repository cutoff =
367 Removed: let predicate (commit : t) =
368 Removed: let ts, _ = commit.author.Git.User.date in
369 Removed: Int64.compare ts cutoff >= 0
370 Removed: in
371 Removed: (* Walk up to 1000 commits; stop collecting once we pass the cutoff *)
372 Removed: let* head_hash = resolve_head_hash repository in
373 Removed: let module S = Set.Make (String) in
374 Removed: let rec walk collected seen queue =
375 Removed: match queue with
376 Removed: | [] -> Lwt_result.return (List.rev collected)
377 Removed: | (_, h) :: rest ->
378 Removed: if S.mem h seen then walk collected seen rest
379 Removed: else
380 Removed: let seen = S.add h seen in
381 Removed: let* commit = of_id repository h in
382 Removed: let ts, _ = commit.author.Git.User.date in
383 Removed: if Int64.compare ts cutoff < 0 then
384 Removed: (* This commit is too old; don't enqueue its parents *)
385 Removed: walk collected seen rest
386 Removed: else
387 Removed: let new_queue =
388 Removed: List.filter_map
389 Removed: (fun p ->
390 Removed: if S.mem p seen then None
391 Removed: else Some (commit.author.Git.User.date, p))
392 Removed: commit.parents
393 Removed: in
394 Removed: let queue =
395 Removed: List.merge
396 Removed: (fun ((a_ts, _), _) ((b_ts, _), _) -> Int64.compare b_ts a_ts)
397 Removed: rest new_queue
398 Removed: in
399 Removed: let collected =
400 Removed: if predicate commit then commit :: collected else collected
401 Removed: in
402 Removed: walk collected seen queue
403 Removed: in
404 Removed: walk [] S.empty [ ((Int64.max_int, None), Store.Hash.to_hex head_hash) ]
405 365 end
406 366
407 367 module Reference = struct
lib/resolvers.mli
index aa56ff93..e96d1e92 100644..100644
@@ -76,7 +76,6 @@
76 76 repository -> int -> (t -> bool) -> (t list, error) Lwt_result.t
77 77
78 78 val recent : repository -> int -> (t list, error) Lwt_result.t
79 Removed: val since : repository -> int64 -> (t list, error) Lwt_result.t
80 79 end
81 80
82 81 (** {1 References} *)
lib/static/styles.css
index ef46379e..b3d2d9b0 100644..100644
@@ -508,28 +508,7 @@
508 508 }
509 509
510 510 /* Summary page layout */
511 Removed: .summary-readme:empty {
512 Removed: display: none;
513 Removed: }
514 511
515 Removed: /* Chart container */
516 Removed: .chart-container {
517 Removed: width: 100%;
518 Removed: overflow-x: auto;
519 Removed: }
520 Removed:
521 Removed: .chart-commit-frequency {
522 Removed: width: 100%;
523 Removed: height: auto;
524 Removed: display: block;
525 Removed: }
526 Removed:
527 Removed: /* "Show previous commits" link on summary page */
528 Removed:
529 Removed: .summary-more {
530 Removed: text-align: center;
531 Removed: margin: 1em 0;
532 Removed: }
533 512
534 513 /* Pill color variants — WCAG AA contrast against their backgrounds */
535 514
lib/views/repo.ml
index 3b87d69a..9236e0a4 100644..100644
@@ -196,16 +196,7 @@
196 196
197 197 (** {1 Pages} *)
198 198
199 Removed: let summary context ?readme frequency =
200 Removed: let activity =
201 Removed: [
202 Removed: Ui.heading ~level:3 [ Ui.text "Commit activity (past 30 days)" ];
203 Removed: Ui.block ~class_:"chart-container"
204 Removed: [ Charts.commit_frequency ~chart_width:600 ~chart_height:200 frequency ];
205 Removed: Ui.paragraph ~class_:"summary-more"
206 Removed: [ Components.route_link (Commits context.repo) "View all commits" ];
207 Removed: ]
208 Removed: in
199 Added: let summary context ?readme () =
209 200 let readme_panel =
210 201 match readme with
211 202 | None -> Ui.nothing
@@ -219,13 +210,7 @@
219 210 ~href:(Components.clone_url context.repo)
220 211 "Clone repo";
221 212 ]
222 Removed: [
223 Removed: Ui.block ~class_:"summary-layout"
224 Removed: [
225 Removed: Ui.block ~class_:"summary-commits" activity;
226 Removed: Ui.block ~class_:"summary-readme" [ readme_panel ];
227 Removed: ];
228 Removed: ]
213 Added: [ readme_panel ]
229 214
230 215 let commits ?filter_type ?author ?committer ~page_number ~has_prev ~has_next
231 216 context commits =