fix(reports): yonetici ozeti Son 6 Ay tablosu ay sonunda 3-5 aya dusuyordu - #5
fix(reports): yonetici ozeti Son 6 Ay tablosu ay sonunda 3-5 aya dusuyordu
#5ersinkoc wants to merge 2 commits into
Conversation
Kok neden: strtotime('-N month') gun tasmasini kirmaz. Ayin 29-31'inde
hedef ayda o gun yoksa sonuc bir SONRAKI aya tasiyor; ayni 'Y-m' anahtari
iki kez uretiliyor ve api/dashboard_charts.php'deki 12 aylik trend
penceresi 7-11 aylik map'e cokuyordu. Kayip aylarin riskleri trend
graginde hic sayilmiyor, SQL penceresinin alt siniri (:since) da bir ay
geriden geliyordu.
Cozum: ay aritmetigi ayin 1'ine sabitlenen recent_months() yardimcisi
(includes/functions.php) eklendi; uc nokta bu yardimciyi kullaniyor.
1. gunden cikarilan ay asla tasamaz.
Kanit: .temp_files altindaki proof-script oncesinde 11 prob gununden
9'unda FAIL (buckets=7, since kayik), sonrasi PASS. Dayanikli regresyon
testi tools/trend_months_test.php olarak eklendi (22 kontrol: ay sonu
gunleri, artik yil, yil siniri, count sinirlari, uc nokta baglantisi;
DB gerektirmez, php tools/trend_months_test.php ile calisir).
…yordu Kok neden (PR #1 ile ailesi): strtotime('-N month') gun tasmasini kirmaz. Ayin 29-31'inde hedef ayda o gun yoksa sonuc bir SONRAKI aya tasiyor; reports/executive_summary.php'deki "Son 6 Ay" trend map'i yinelenen 'Y-m' anahtarlarindan 3-5 aya kadar kuculuyordu (2026-05-31 tabaninda 2026-02 ve 2026-04 tamamen kayboluyordu) ve SQL penceresinin alt siniri Temmuz 29-31'de bir ay geride kaliyordu (2026-03-01 yerine 2026-02-01). Cozum: pencere ayin 1'ine sabitlenen recent_months(6) ile kuruluyor (PR #1'de eklenen yardimci); :since degeri en eski ayin 1'inden turetiliyor. Kanit: round-owned proof-script oncesinde 12 prob gununden 9'unda FAIL (rows=3-5, since kayik), sonrasi PASS. Dayanikli regresyon testi tools/trend_months_test.php genisletildi (25 kontrol: 6 aylik pencere + yonetici ozeti baglanti guvenligi; DB gerektirmez). Not: bu dal PR #1 (fix/dashboard-trend-month-window) uzerine istiflidir; trend_months_test.php recent_months()'a baglidir. PR #1 birlestiginde base otomatik olarak main'e doner.
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tools/trend_months_test.php">
<violation number="1" location="tools/trend_months_test.php:127">
P2: If `executive_summary.php` keeps `recent_months(6)` but regresses the `:since` boundary, this test still passes. Assert that the consumer derives `$since` from `$monthKeys[0] . '-01'` (or otherwise exercise that boundary) so the reported fix is covered.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| $srcExec = (string)file_get_contents(__DIR__ . '/../reports/executive_summary.php'); | ||
| check('reports/executive_summary.php recent_months() kullaniyor', | ||
| str_contains($srcExec, 'recent_months(6)')); |
There was a problem hiding this comment.
P2: If executive_summary.php keeps recent_months(6) but regresses the :since boundary, this test still passes. Assert that the consumer derives $since from $monthKeys[0] . '-01' (or otherwise exercise that boundary) so the reported fix is covered.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tools/trend_months_test.php, line 127:
<comment>If `executive_summary.php` keeps `recent_months(6)` but regresses the `:since` boundary, this test still passes. Assert that the consumer derives `$since` from `$monthKeys[0] . '-01'` (or otherwise exercise that boundary) so the reported fix is covered.</comment>
<file context>
@@ -0,0 +1,147 @@
+
+$srcExec = (string)file_get_contents(__DIR__ . '/../reports/executive_summary.php');
+check('reports/executive_summary.php recent_months() kullaniyor',
+ str_contains($srcExec, 'recent_months(6)'));
+check('yonetici ozeti bozuk strtotime ay ifadeleri kaldirildi',
+ !str_contains($srcExec, 'strtotime("-{') && !str_contains($srcExec, "strtotime('-5 month')"));
</file context>
|
Teşekkürler. Dört bulguyu da doğruladım, dördü de gerçekti. Özellikle schema.sql'deki eksik users tablosu ciddiydi: belgelenmiş Düzeltmeleri main'e bağımsız olarak uyguladım (2530ae1). PR'ları merge
cubic'in son admin korumasına yaptığı P1 eleştirisini de hesaba kattım: Eklenen regresyon testleri:
#7 açık kalıyor - orada karşılığı olmayan bir test var, kapsamı Tekrar teşekkürler, başka bulgunuz olursa memnuniyetle bakarım. |
Hata
Yönetim özetindeki "Son 6 Ay" tablosu (açıılan / kapanan / net), rapor ayın 29–31'ine denk gelen bir günde istendiğinde yanlış pencere üretiyordu:
2026-02ve2026-04tamamen kayboluyordu),:sincebir ay geriden geliyordu (2026-03-01yerine2026-02-01).Kök neden
reports/executive_summary.php:88-93pencereyi şöyle kuruyordu:strtotime('-N month')gün taşmasını kırmaz: hedef ayda o gün yoksa sonuç bir sonraki aya taşar, aynıY-manahtarı iki kez üretilir ve map küçülür. PR #1'deki dashboard hatasıyla aynı aile.Çözüm
recent_months(6)yardımcısıyla kuruluyor (PR fix(dashboard): trend grafigi ay sonunda 7-11 aya dusuyordu #1'deincludes/functions.php'e eklendi — bu PR o dosyaya dokunmaz).$sincepencerenin en eski ayının 1'i olarak türetilir ($monthKeys[0] . '-01').Kanıt ve doğrulama
2026-05-31 rows=4 missing 2026-02,2026-04,2026-07-31 rows=3 since=2026-03-01 (expected 2026-02-01)(exit 1).:since(exit 0).tools/trend_months_test.phpartık 25 kontrol ile 6 aylık pencereyi ve yönetici özeti bağlantısını da koruyor (DB gerektirmez:php tools/trend_months_test.php).php -l: temiz. Tam kapı testi (tools/smoke_test.php) bu Windows kutusunda çevresel nedenlerle çalışmıyor (/var/www/riskops+config/database.php+ MySQL bekliyor); hatanın bu değişiklikle ilişkisi yok.Kapsam çiti
Bu PR yalnızca
reports/executive_summary.phpvetools/trend_months_test.phpdosyalarını değiştirir.Neden istifli (stacked)?
trend_months_test.php, PR #1'de eklenenrecent_months()yardımcısına bağlıdır ve o yardımcı bu PR'ın çitinin dışındadır. Bu yüzden dal, PR #1 dalının (fix/dashboard-trend-month-window) üzerine istiflenmiştir: PR'nin diff'i tam olarak yukarıdaki iki dosyayı gösterir. PR #1 birleştiğinde GitHub bu PR'nin base'ini otomatik olarakmain'e çevirir.Not (upstream): Bu PR fork'tan
CodeByPinar/riskops:main'e açılmıştır. Dal, aynı anda açık olan dashboard düzeltmesini de içerir (fix/dashboard-trend-month-windowdalındaki commit); o PR birleşene kadar bu PR'nin diff'i dashboard dosyalarını da gösterir. Birleştirme sırası: önce dashboard PR'i, sonra bu PR.Summary by cubic
Fixes month-end date overflow in trend windows so the dashboard chart and the executive summary's "Last 6 Months" table always show the full 12 or 6 months.
Previously,
strtotime('-N month')skipped the target month when the current day (29th–31st) didn't exist there, shrinking windows to as few as 3 rows and dropping months from the opened/closed counts. The window is now built from the newrecent_months()helper, which anchors to the 1st of each month, and$sincederives from the oldest key.Bug Fixes
api/dashboard_charts.phpandreports/executive_summary.phpnow userecent_months()instead ofstrtotime('-N month').recent_months()toincludes/functions.php; no migration needed.tools/trend_months_test.phpwith 25 checks covering month-end days, leap years, and consumer wiring; runs without a database.Written for commit 331929c. Summary will update on new commits.