Commit f8442ea
Fix baseline badge level change detection, CDN purge, and email notification (#2763)
When a project earns or loses a baseline badge level, the system was not
detecting the change, so no congratulations/warning flash message or email
was sent. Things worked fine in the metal series, but while we were
adding baseline we stubbed out parts because we added only one baseline
level at first. However, that's no longer true.
Also, update_all_badge_percentages (run after criteria rule
changes) was not purging the CDN, leaving stale badge images cached.
Specific fixes:
- current_working_level: return project.baseline_badge_level (e.g.
'in_progress', 'baseline-1') for baseline sections, not the fixed
criteria_level string. This makes gain/loss detection work for
baseline the same way it already worked for metal badges.
- update_all_badge_percentages: call FastlyRails.purge_all on completion.
When criteria rules change and all badge percentages are recalculated,
the CDN cache is now cleared automatically. No-op in test/development
where Fastly credentials are absent. To force recalculation and purge
the CDN cache in production:
heroku run --app production-bestpractices rake update_all_badge_percentages
- email_owner: accept badge_suffix parameter ('badge' or 'baseline')
from caller instead of deriving it internally, keeping structural
decisions out of the mailer.
- Sections.badge_url_suffix: new single source of truth for the badge
image URL path suffix per series type, backed by BADGE_URL_SUFFIX map.
Both call sites (controller and view) now use this instead of
independent ternary expressions.
- gained_level.text.erb: use @badge_suffix in badge embedding snippets
so baseline badge earners see /baseline not /badge. Also fix a
pre-existing bug where the HTML snippet had <% @hostname %> (missing =)
silently dropping the hostname.
- docs/baseline_update.md: document the recalculation migration step
needed when completing a baseline update transition (activating future
criteria), and note that it automatically purges the CDN.
- Tests: fix broken current_working_level test (was asserting old wrong
behavior), add explicit in_progress->baseline-1 test, add email_owner
tests for metal vs baseline suffix.
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 1ed9cdc commit f8442ea
9 files changed
Lines changed: 108 additions & 13 deletions
File tree
- app
- controllers
- mailers
- models
- views
- projects
- report_mailer
- config/initializers
- docs
- test
- controllers
- mailers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1569 | 1569 | | |
1570 | 1570 | | |
1571 | 1571 | | |
| 1572 | + | |
1572 | 1573 | | |
1573 | | - | |
| 1574 | + | |
1574 | 1575 | | |
1575 | 1576 | | |
1576 | 1577 | | |
1577 | 1578 | | |
1578 | 1579 | | |
1579 | 1580 | | |
1580 | | - | |
| 1581 | + | |
| 1582 | + | |
1581 | 1583 | | |
1582 | 1584 | | |
1583 | 1585 | | |
1584 | 1586 | | |
1585 | 1587 | | |
1586 | | - | |
1587 | | - | |
| 1588 | + | |
| 1589 | + | |
1588 | 1590 | | |
1589 | 1591 | | |
1590 | 1592 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| 93 | + | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
685 | 691 | | |
686 | 692 | | |
687 | 693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
162 | 178 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | | - | |
443 | | - | |
| 442 | + | |
| 443 | + | |
444 | 444 | | |
445 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
446 | 488 | | |
447 | 489 | | |
448 | 490 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2064 | 2064 | | |
2065 | 2065 | | |
2066 | 2066 | | |
2067 | | - | |
| 2067 | + | |
2068 | 2068 | | |
2069 | 2069 | | |
2070 | 2070 | | |
2071 | | - | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
2072 | 2081 | | |
2073 | 2082 | | |
2074 | 2083 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
29 | 47 | | |
30 | 48 | | |
31 | 49 | | |
| |||
0 commit comments