Skip to content

Commit 8e7b2ea

Browse files
committed
update progress
1 parent 24630db commit 8e7b2ea

File tree

2 files changed

+61
-14
lines changed

2 files changed

+61
-14
lines changed

scripts/analyze_progress.exs

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,64 @@
11
defmodule ProgressAnalyzer do
22
@moduledoc false
3-
def analyze_file(path) do
3+
require Logger
4+
5+
def analyze_file(path, verbose \\ false) do
46
stats =
57
path
68
|> File.read!()
79
|> YamlElixir.read_from_string!()
810
|> count_statuses()
911

10-
display_stats(stats)
12+
display_stats(stats, verbose)
1113
end
1214

1315
defp count_statuses(yaml) do
1416
# Initialize counters
15-
initial_counts = %{completed: 0, skipped: 0, remaining: 0, undecided: 0}
17+
initial_counts = %{completed: 0, skipped: 0, remaining: 0, undecided: 0, remaining_columns: []}
1618

1719
# Flatten and count all column statuses
1820
Enum.reduce(yaml, initial_counts, fn table, acc ->
1921
columns = table |> Map.values() |> List.first()
2022

2123
Enum.reduce(columns, acc, fn column, inner_acc ->
22-
{_col, status} = Enum.at(Map.to_list(column), 0)
24+
{col, status} = Enum.at(Map.to_list(column), 0)
2325

2426
case status do
25-
1 -> Map.update!(inner_acc, :completed, &(&1 + 1))
26-
-2 -> Map.update!(inner_acc, :undecided, &(&1 + 1))
27-
-1 -> Map.update!(inner_acc, :skipped, &(&1 + 1))
28-
0 -> Map.update!(inner_acc, :remaining, &(&1 + 1))
27+
1 ->
28+
Map.update!(inner_acc, :completed, &(&1 + 1))
29+
30+
-2 ->
31+
Map.update!(inner_acc, :undecided, &(&1 + 1))
32+
33+
-1 ->
34+
Map.update!(inner_acc, :skipped, &(&1 + 1))
35+
36+
0 ->
37+
inner_acc
38+
|> Map.update!(:remaining, &(&1 + 1))
39+
|> Map.update!(:remaining_columns, &(&1 ++ ["#{table |> Map.keys() |> List.first()}.#{col}"]))
2940
end
3041
end)
3142
end)
3243
end
3344

34-
defp display_stats(%{completed: done, skipped: skipped, remaining: todo, undecided: undecided}) do
45+
defp display_stats(
46+
%{
47+
completed: done,
48+
skipped: skipped,
49+
remaining: todo,
50+
undecided: undecided,
51+
remaining_columns: remaining_columns
52+
},
53+
verbose
54+
) do
3555
total = done + skipped + todo + undecided
3656
done_pct = percentage(done, total)
3757
skipped_pct = percentage(skipped, total)
3858
todo_pct = percentage(todo, total)
3959
undecided_pct = percentage(undecided, total)
4060

41-
IO.puts("""
61+
base_output = """
4262
Migration Progress Report
4363
========================
4464
@@ -56,7 +76,22 @@ defmodule ProgressAnalyzer do
5676
Progress:
5777
---------
5878
[#{progress_bar(done_pct, skipped_pct, todo_pct, undecided_pct)}]
59-
""")
79+
"""
80+
81+
if_result =
82+
if verbose do
83+
base_output <>
84+
"""
85+
86+
Remaining Columns:
87+
------------------
88+
#{Enum.join(remaining_columns, "\n")}
89+
"""
90+
else
91+
base_output
92+
end
93+
94+
IO.puts(if_result)
6095
end
6196

6297
defp percentage(part, total) when total > 0 do
@@ -77,10 +112,22 @@ defmodule ProgressAnalyzer do
77112
end
78113

79114
case System.argv() do
115+
[filename, "-v"] ->
116+
ProgressAnalyzer.analyze_file(filename, true)
117+
118+
["-v", filename] ->
119+
ProgressAnalyzer.analyze_file(filename, true)
120+
80121
[filename] ->
81-
ProgressAnalyzer.analyze_file(filename)
122+
ProgressAnalyzer.analyze_file(filename, false)
82123

83124
_ ->
84-
IO.puts("Usage: elixir analyze_progress.exs <filename>")
125+
IO.puts("""
126+
Usage: elixir analyze_progress.exs [-v] <filename>
127+
128+
Options:
129+
-v Show detailed remaining columns list
130+
""")
131+
85132
System.halt(1)
86133
end

scripts/v1-progress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
- bounty_charge_id: -1
138138
- github_res_comment_id: 0
139139
- info: 0
140-
- share: 0
140+
- share: -1
141141
- "Company":
142142
- id: -1
143143
- created_at: -1

0 commit comments

Comments
 (0)