File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# api
22
3+ ## 10x.18.5 - 28 February 2025
4+ - Fix bug on wiki metrics recoding
5+
36## 10x.18.4 - 19 February 2025
47- Fix job definition in UpdateWikiDailyMetricJob class
58- Update actions/cache in github workflow to version 4 to pass CI
Original file line number Diff line number Diff line change @@ -16,12 +16,14 @@ public function saveMetrics(Wiki $wiki): void
1616 $ isDeleted = (bool )$ wiki ->deleted_at ;
1717 if ($ oldRecord ) {
1818 if ($ oldRecord ->is_deleted ) {
19- \Log::info ("WikiMetrics is deleted, no new record for WikiMetrics ID {$ wiki ->id }. " );
19+ \Log::info ("Wiki is deleted, no new record for WikiMetrics ID {$ wiki ->id }. " );
2020 return ;
2121 }
22- if ($ oldRecord ->pages === $ todayPageCount ) {
23- \Log::info ("Page count unchanged for WikiMetrics ID {$ wiki ->id }, no new record added. " );
24- return ;
22+ if (!$ isDeleted ) {
23+ if ($ oldRecord ->pages === $ todayPageCount ) {
24+ \Log::info ("Page count unchanged for WikiMetrics ID {$ wiki ->id }, no new record added. " );
25+ return ;
26+ }
2527 }
2628 }
2729 WikiDailyMetrics::create ([
Original file line number Diff line number Diff line change @@ -49,5 +49,32 @@ public function testDoesNotAddDuplicateRecordsWithOnlyDateChange()
4949 'date ' => Carbon::today ()->toDateString ()
5050 ]);
5151 }
52+
53+ public function testAddRecordsWikiIsDeleted ()
54+ {
55+ $ wiki = Wiki::factory ()->create ([
56+ 'domain ' => 'thisfake.wikibase.cloud '
57+ ]);
58+ //Insert an old metric value for a wiki
59+ WikiDailyMetrics::create ([
60+ 'id ' => $ wiki ->id . '_ ' . Carbon::yesterday ()->toDateString (),
61+ 'wiki_id ' => $ wiki ->id ,
62+ 'date ' => Carbon::yesterday ()->toDateString (),
63+ 'pages ' => 0 ,
64+ 'is_deleted ' => 1
65+ ]);
66+ //delete the wiki
67+ $ wiki ->delete ();
68+ $ wiki ->save ();
69+
70+ (new WikiMetrics ())->saveMetrics ($ wiki );
71+
72+ //Assert No new record was created for today
73+ $ this ->assertDatabaseMissing ('wiki_daily_metrics ' , [
74+ 'wiki_id ' => $ wiki ->id ,
75+ 'is_deleted ' => 1 ,
76+ 'date ' => now ()->toDateString ()
77+ ]);
78+ }
5279}
5380
You can’t perform that action at this time.
0 commit comments