Skip to content

Commit 3987b76

Browse files
alexp8Sneer-ra2
andauthored
Revert secondsInQueue to use updated_at (#459)
* add more logs and update secondsInQueue (#456) Co-authored-by: Sneer-ra2 <[email protected]> * set AutoSaveInterval to 0 * update secondsInQueue to use updated_at --------- Co-authored-by: Sneer-ra2 <[email protected]>
1 parent 0ceea9f commit 3987b76

File tree

4 files changed

+7
-17
lines changed

4 files changed

+7
-17
lines changed

cncnet-api/app/Extensions/Qm/Matchup/PlayerMatchupHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public function matchup(): void
5454
if ($matchableOpponents->count() < $numberOfOpponentsNeeded)
5555
{
5656
Log::debug("FindOpponent ** Not enough players for match yet, ladder: $ladder->abbreviation, player: $playerName");
57-
$this->qmPlayer->touch();
5857
return;
5958
}
6059

@@ -78,7 +77,6 @@ public function matchup(): void
7877
if (count($commonQmMaps) < 1)
7978
{
8079
Log::info("FindOpponent ** No common maps available for ladder: $ladder->abbreviation, player: $playerName");
81-
$this->qmPlayer->touch();
8280
return;
8381
}
8482

cncnet-api/app/Extensions/Qm/Matchup/TeamMatchupHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public function matchup(): void
7878
{
7979
Log::info(" ❌ MATCH FAILED: Not enough players ({$matchableOpponentsCount}/{$numberOfOpponentsNeeded} needed)");
8080
Log::info("=== TeamMatchup END for {$playerInQueue} - NO MATCH ===\n");
81-
$this->qmPlayer->touch();
8281
return;
8382
}
8483

@@ -120,7 +119,6 @@ public function matchup(): void
120119
{
121120
Log::info(" ❌ MATCH FAILED: No common maps available between all players");
122121
Log::info("=== TeamMatchup END for {$playerInQueue} - NO MATCH ===\n");
123-
$this->qmPlayer->touch();
124122
return;
125123
}
126124

cncnet-api/app/Http/Services/QuickMatchService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ public function getMatchableOpponents(QmQueueEntry $currentQmQueueEntry, Collect
355355
continue;
356356
}
357357

358-
// (updated_at - created_at) / 60 = seconds duration player has been waiting in queue
359-
$pointsTime = ((strtotime($currentQmQueueEntry->updated_at) - strtotime($currentQmQueueEntry->created_at))) * $ladder->qmLadderRules->points_per_second;
358+
// Calculate wait time bonus using secondsinQueue()
359+
$pointsTime = $currentQmQueueEntry->secondsinQueue() * $ladder->qmLadderRules->points_per_second;
360360

361361
// is the opponent within the point filter
362362
if ($pointsTime + $ladder->qmLadderRules->max_points_difference > abs($currentQmQueueEntry->points - $opponent->points))
@@ -460,8 +460,8 @@ public function getEntriesInPointRange(QmQueueEntry $currentQmQueueEntry, Collec
460460
continue;
461461
}
462462

463-
// (updated_at - created_at) / 60 = seconds duration player has been waiting in queue
464-
$pointsTime = ((strtotime($currentQmQueueEntry->updated_at) - strtotime($currentQmQueueEntry->created_at))) * $pointsPerSecond;
463+
// Calculate wait time bonus using secondsinQueue()
464+
$pointsTime = $currentQmQueueEntry->secondsinQueue() * $pointsPerSecond;
465465

466466
// is the opponent within the point filter
467467
if ($pointsTime + $maxPointsDifference > abs($currentQmQueueEntry->points - $opponent->points))

cncnet-api/app/Models/QmQueueEntry.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@ public function ladderHistory()
1919

2020
public function secondsinQueue()
2121
{
22-
$createdAt = $this->created_at;
23-
24-
// Convert timestamp to Carbon instance
25-
$createdAtCarbon = Carbon::parse($createdAt);
26-
27-
// Calculate the difference in seconds from created_at to NOW
28-
$secondsDifference = now()->diffInSeconds($createdAtCarbon);
29-
30-
return $secondsDifference;
22+
// Calculate the difference between updated_at and created_at
23+
// updated_at is touched by matchup handlers when no match is found
24+
return $this->updated_at->diffInSeconds($this->created_at);
3125
}
3226
}

0 commit comments

Comments
 (0)