Skip to content

Commit 26d5593

Browse files
authored
Merge branch 'main' into de/laravel12
2 parents 85d6686 + 0219964 commit 26d5593

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

app/Helper/MWTimestampHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
namespace App\Helper;
1010

1111
use Carbon\CarbonImmutable;
12+
use Carbon\Exceptions\InvalidFormatException;
1213

1314
class MWTimestampHelper {
1415
private const MWTimestampFormat = 'YmdHis';
1516

1617
public static function getCarbonFromMWTimestamp(string $MWTimestamp): CarbonImmutable {
1718
$carbon = CarbonImmutable::createFromFormat(self::MWTimestampFormat, $MWTimestamp);
18-
if ($carbon === false) {
19-
throw new \Exception('Unable to create Carbon object');
19+
if ($carbon === null) {
20+
throw new InvalidFormatException('Unable to create Carbon object');
2021
}
2122

2223
return $carbon;

app/Http/Controllers/ConversionMetricController.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ public function index(Request $request) {
3131
}
3232
$time_before_wiki_abandoned_days = null;
3333
$time_to_engage_days = null;
34+
$daysSinceLastEdit = null;
3435

35-
if (!is_null($wikiLastEditedTime) && ($wikiLastEditedTime->diffInDays($current_date, false) >= 90)) {
36-
$time_before_wiki_abandoned_days = $wiki->created_at->diffInDays($wikiLastEditedTime, false);
36+
if ($wikiLastEditedTime !== null) {
37+
$daysSinceLastEdit = (int) $wikiLastEditedTime->diffInDays($current_date, false);
38+
}
39+
40+
if ($daysSinceLastEdit !== null && $daysSinceLastEdit >= 90) {
41+
$time_before_wiki_abandoned_days = (int) $wiki->created_at->diffInDays($wikiLastEditedTime, false);
3742
}
3843
if ($wikiFirstEditedTime !== null) {
39-
$time_to_engage_days = $wiki->created_at->diffInDays($wikiFirstEditedTime, false);
44+
$time_to_engage_days = (int) $wiki->created_at->diffInDays($wikiFirstEditedTime, false);
4045
}
4146
$wiki_number_of_editors = $wiki->wikiSiteStats()->first()['activeusers'] ?? null;
4247

app/Jobs/PlatformStatsSummaryJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ 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-
$diff = $lastTimestamp->diffInSeconds($currentTime);
135+
$diff = (int) $lastTimestamp->diffInSeconds($currentTime, true);
136136

137137
if ($diff <= $this->inactiveThreshold) {
138138
$editedLast90DaysWikis[] = $wiki;

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-
$emptyWikiDays = $createdAt->diffInDays($now);
37+
$emptyWikiDays = (int) $createdAt->diffInDays($now, true);
3838

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

0 commit comments

Comments
 (0)