Skip to content

Commit e5037b9

Browse files
dati18outdooracorn
andauthored
Update comments based on suggestions
Co-authored-by: Ollie <43674967+outdooracorn@users.noreply.github.com>
1 parent 1d50bc1 commit e5037b9

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

app/Http/Controllers/ConversionMetricController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ public function index(Request $request) {
3434
$daysSinceLastEdit = null;
3535

3636
if ($wikiLastEditedTime !== null) {
37-
// Cast to int to avoid fractional-day values in CSV/JSON and keep cutoff logic predictable.
37+
// cast to int to retain Carbon 2 behaviour of using whole days
3838
$daysSinceLastEdit = (int) $wikiLastEditedTime->diffInDays($current_date, false);
3939
}
4040

4141
if ($daysSinceLastEdit !== null && $daysSinceLastEdit >= 90) {
42-
// Keep exported duration as whole days for stable reporting.
42+
// cast to int to retain Carbon 2 behaviour of using whole days
4343
$time_before_wiki_abandoned_days = (int) $wiki->created_at->diffInDays($wikiLastEditedTime, false);
4444
}
4545
if ($wikiFirstEditedTime !== null) {
46-
// Keep exported duration as whole days for stable reporting.
46+
// cast to int to retain Carbon 2 behaviour of using whole days
4747
$time_to_engage_days = (int) $wiki->created_at->diffInDays($wikiFirstEditedTime, false);
4848
}
4949
$wiki_number_of_editors = $wiki->wikiSiteStats()->first()['activeusers'] ?? null;

app/Jobs/PlatformStatsSummaryJob.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ public function prepareStats(array $allStats, $wikis): array {
132132
// is it edited in the last 90 days?
133133
if (!is_null($stats['lastEdit'])) {
134134
$lastTimestamp = MWTimestampHelper::getCarbonFromMWTimestamp(intval($stats['lastEdit']));
135-
// Carbon can return fractional seconds; cast to int so threshold checks use whole-second precision.
135+
// cast to int retain Carbon 2 behaviour of using whole days
136+
// pass `$absolute = true` argument to retain Carbon 2 behaviour of returning an absolute diff
136137
$diff = (int) $lastTimestamp->diffInSeconds($currentTime, true);
137138

138139
if ($diff <= $this->inactiveThreshold) {

app/Jobs/SendEmptyWikiNotificationsJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function checkIfWikiIsOldAndEmpty(Wiki $wiki) {
3434
$emptyDaysThreshold = config('wbstack.wiki_empty_notification_threshold');
3535
$createdAt = $wiki->created_at;
3636
$now = CarbonImmutable::now();
37-
// Normalize to whole days so comparisons with the integer config threshold stay deterministic.
37+
// cast to int to retain Carbon 2 behaviour of using whole days
3838
$emptyWikiDays = (int) $createdAt->diffInDays($now, true);
3939

4040
$firstEdited = $wiki->wikiLifecycleEvents->first_edited;

0 commit comments

Comments
 (0)