Skip to content

Commit

Permalink
🐛 Fix points_enabled (#2783)
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrLevin authored Jul 19, 2024
1 parent 0ed27a4 commit a443fa2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Backend/LeaderboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function getLeaderboard(
}

public static function getMonthlyLeaderboard(Carbon $date): Collection {
if (auth()->user()?->likesEnabled === false) {
if (auth()->user()?->points_enabled === false) {
return collect();
}

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Resources/TransportResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class TransportResource extends JsonResource
{
public function toArray($request): array {
$likesEnabled = $request->user()?->likesEnabled ?? true;
$pointsEnabled = $request->user()?->points_enabled ?? true;
/** @var Checkin $this */
return [
'trip' => (int) $this->trip->id,
Expand All @@ -38,7 +38,7 @@ public function toArray($request): array {
'lineName' => (string) $this->trip->linename,
'journeyNumber' => $this->trip->journey_number,
'distance' => (int) $this->distance,
'points' => (int) $likesEnabled ? $this->points : 0,
'points' => (int) $pointsEnabled ? $this->points : 0,
'duration' => (int) $this->duration,
'manualDeparture' => $this->manual_departure?->toIso8601String(),
'manualArrival' => $this->manual_arrival?->toIso8601String(),
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Resources/UserAuthResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
class UserAuthResource extends JsonResource
{
public function toArray($request): array {
$pointsEnabled = $request->user()?->points_enabled ?? true;
return [
'id' => (int) $this->id,
'displayName' => (string) $this->name,
Expand All @@ -37,7 +38,7 @@ public function toArray($request): array {
'totalDistance' => (float) $this->train_distance,
'trainDuration' => (int) $this->train_duration, // @deprecated: remove after 2024-08
'totalDuration' => (int) $this->train_duration,
'points' => (int) $this->points,
'points' => (int) $pointsEnabled ? $this->points : 0,
'mastodonUrl' => $this->mastodonUrl ?? null,
'privateProfile' => (bool) $this->private_profile,
'preventIndex' => $this->prevent_index,
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Resources/UserBaseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class UserBaseResource extends JsonResource
{
public function toArray($request): array {
$likesEnabled = $request->user()?->likesEnabled ?? true;
$pointsEnabled = $request->user()?->points_enabled ?? true;
return [
'id' => (int) $this->id,
'displayName' => (string) $this->name,
Expand All @@ -19,7 +19,7 @@ public function toArray($request): array {
'totalDistance' => (float) $this->train_distance,
'trainDuration' => (int) $this->train_duration, // @deprecated: remove after 2024-08
'totalDuration' => (int) $this->train_duration,
'points' => (int) $likesEnabled ? $this->points : 0,
'points' => (int) $pointsEnabled ? $this->points : 0,
'mastodonUrl' => $this->mastodonUrl ?? null,
'privateProfile' => (bool) $this->private_profile,
'preventIndex' => $this->prevent_index,
Expand Down

0 comments on commit a443fa2

Please sign in to comment.