Skip to content

Commit

Permalink
🔥 drop deprecated things (#2281)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu authored Jan 21, 2024
1 parent 46ca3b1 commit e75e368
Show file tree
Hide file tree
Showing 17 changed files with 12 additions and 248 deletions.
5 changes: 5 additions & 0 deletions API_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ In this we try to keep track of changes to the API.
Primarily this should document changes that are not backwards compatible or belongs to already documented endpoints.
This is to help you keep track of the changes and to help you update your code accordingly.

## 2024-01-21

The attribute `twitter` in the `User` Model is already always `null` and will be removed after 2024-03.
Please prepare your code accordingly.

## 2023-11-23

The attribute `type` in the `Status` Model is marked as deprecated and now returns a blank string for all statuses as it
Expand Down
7 changes: 3 additions & 4 deletions app/Http/Controllers/API/v1/TransportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use App\Http\Controllers\Backend\Transport\TrainCheckinController;
use App\Http\Controllers\HafasController;
use App\Http\Controllers\TransportController as TransportBackend;
use App\Http\Resources\TripResource;
use App\Http\Resources\StationResource;
use App\Http\Resources\StatusResource;
use App\Http\Resources\TripResource;
use App\Models\Event;
use App\Models\Station;
use Carbon\Carbon;
Expand Down Expand Up @@ -240,15 +240,14 @@ public function departures(Request $request, string $name): JsonResponse {
*/
public function getTrip(Request $request): JsonResponse {
$validated = $request->validate([
'tripId' => ['required_without:hafasTripId', 'string'], //ToDo deprecated: remove after 2023-02-28
'hafasTripId' => ['required_without:tripId', 'string'],
'hafasTripId' => ['required', 'string'],
'lineName' => ['required', 'string'],
'start' => ['required', 'numeric', 'gt:0'],
]);

try {
$trip = TrainCheckinController::getHafasTrip(
$validated['hafasTripId'] ?? $validated['tripId'], //ToDo deprecated: change to hafasTripId after 2023-02-28
$validated['hafasTripId'],
$validated['lineName'],
(int) $validated['start']
);
Expand Down
98 changes: 0 additions & 98 deletions app/Http/Controllers/Backend/Admin/DashboardController.php

This file was deleted.

34 changes: 0 additions & 34 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Controllers;

use Carbon\Carbon;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
Expand All @@ -11,37 +10,4 @@
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

/**
* @param int $stationId
* @param array $array
* @param Carbon|null $departure
* @param Carbon|null $arrival
*
* @return int|null
* @deprecated This function is only used in TransportController::TrainTrip which is
* deprecated and replaced with other functions
*/
public static function searchForId(
int $stationId,
array $array,
Carbon $departure = null,
Carbon $arrival = null
): ?int {
foreach ($array as $key => $val) {
if ($val['stop']['id'] != $stationId) {
continue;
}
$stopDeparture = Carbon::parse($val['plannedDeparture'] ?? $val['departure']);
$stopArrival = Carbon::parse($val['plannedArrival'] ?? $val['arrival']);
$departureTimeMatches = $departure == null || $departure == $stopDeparture;
$arrivalTimeMatches = $arrival == null || $arrival == $stopArrival;

if ($departureTimeMatches && $arrivalTimeMatches) {
return $key;
}
}

return null;
}
}
30 changes: 0 additions & 30 deletions app/Http/Controllers/Frontend/Admin/DashboardController.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Http/Middleware/PrivacyInterceptionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Support\Facades\Log;

/**
* @deprecated used in api v0 and frontend
* used in frontend
*/
class PrivacyInterceptionMiddleware
{
Expand Down
1 change: 0 additions & 1 deletion app/Http/Resources/LeaderboardUserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public function toArray($request): array {
'profilePicture'=> ProfilePictureController::getUrl($this->user),
'trainDuration' => (int) $this->duration,
'trainDistance' => (float) $this->distance,
'trainSpeed' => 0.0, //deprecated: TODO: remove after 2023-12-31
'points' => (int) $this->points
];
}
Expand Down
1 change: 0 additions & 1 deletion app/Http/Resources/StatusResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function toArray($request): array {
'distance' => (int) $this->checkin->distance,
'points' => (int) $this->checkin->points,
'duration' => (int) $this->checkin->duration,
'speed' => 0.0, //deprecated: TODO: remove after 2023-12-31
'manualDeparture' => $this->checkin->manual_departure?->toIso8601String(),
'manualArrival' => $this->checkin->manual_arrival?->toIso8601String(),
'origin' => new StopoverResource($this->checkin->originStopover),
Expand Down
1 change: 0 additions & 1 deletion app/Http/Resources/UserBaseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public function toArray($request): array {
'profilePicture' => ProfilePictureController::getUrlForUserId($this->id),
'trainDistance' => (float) $this->train_distance,
'trainDuration' => (int) $this->train_duration,
'trainSpeed' => 0.0, //deprecated: TODO: remove after 2023-12-31
'points' => (int) $this->points,
'twitterUrl' => null, //deprecated: TODO: can be removed after 2024-02-29
'mastodonUrl' => $this->mastodonUrl ?? null,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/UserProfileSettingsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function toArray($request): array {
'email' => $this->email,
'emailVerified' => !empty($this->email_verified_at),
'profilePictureSet' => !empty($this->avatar),
'twitter' => null, //deprecated
'twitter' => null, //@deprecated remove after 2024-03
'mastodon' => $this->mastodon_url,
'mastodonVisibility' => $this->socialProfile->mastodon_visibility->value,
];
Expand Down
10 changes: 1 addition & 9 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class User extends Authenticatable implements MustVerifyEmail
'home_id', 'avatar', 'social_profile', 'created_at', 'updated_at', 'userInvisibleToMe'
];
protected $appends = [
'averageSpeed', 'points', 'userInvisibleToMe', 'mastodonUrl', 'train_distance', 'train_duration',
'points', 'userInvisibleToMe', 'mastodonUrl', 'train_distance', 'train_duration',
'following', 'followPending', 'muted', 'isAuthUserBlocked', 'isBlockedByAuthUser',
];
protected $casts = [
Expand Down Expand Up @@ -103,14 +103,6 @@ public function getTrainDurationAttribute(): float {
return Checkin::where('user_id', $this->id)->sum('duration');
}

/**
* @return float
* @deprecated Use speed variable at train_checkins instead
*/
public function getAverageSpeedAttribute(): float {
return $this->train_duration == 0 ? 0 : $this->train_distance / ($this->train_duration / 60);
}

public function socialProfile(): HasOne {
if ($this->hasOne(SocialLoginProfile::class)->count() == 0) {
SocialLoginProfile::create(['user_id' => $this->id]);
Expand Down
11 changes: 0 additions & 11 deletions app/Virtual/Models/CheckinRequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ class CheckinRequestBody
*/
private $eventId;

/**
* @OA\Property (
* title="tweet",
* nullable=true,
* description="The tweet flag is deprecated and will be removed in a future version. For now, it is ignored and check-ins are not tweeted.",
* type="boolean",
* example="false"
* )
*/
private $tweet;

/**
* @OA\Property (
* title="toot",
Expand Down
12 changes: 0 additions & 12 deletions app/Virtual/Models/UserProfileSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,6 @@ class UserProfileSettings
*/
private $profilePictureSet;

/**
* @OA\Property (
* title="twitter",
* description="Deprecated. Always null, since Träwelling doesn't support twitter anymore.",
* nullable=true,
* example="null"
* )
*
* @var string
*/
private $twitter;

/**
* @OA\Property (
* title="mastodon",
Expand Down
4 changes: 0 additions & 4 deletions resources/views/admin/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ class="brand-image me-3" style="width: 30px; opacity: 0.8">
<i class="fa-solid fa-plus"></i>
Trips
</a>
<a class="nav-link" href="{{ route('admin.stats') }}">
<i class="fa-solid fa-chart-line"></i>
Stats
</a>
@endif
</div>
<ul class="navbar-nav ms-auto">
Expand Down
37 changes: 0 additions & 37 deletions resources/views/admin/stats.blade.php

This file was deleted.

3 changes: 0 additions & 3 deletions routes/web/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
Route::middleware('role:admin')->group(static function() {
// these routes are only accessible for admins

Route::get('/stats', [DashboardController::class, 'renderStats'])
->name('admin.stats');

Route::prefix('checkin')->group(function() {
Route::get('/', [CheckinController::class, 'renderStationboard'])
->name('admin.stationboard');
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/APIv1/TransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testGetDeparturesFetchTripAndCheckin(): void {
// Fetch correct trip
$response = $this->get(
uri: '/api/v1/trains/trip'
. '?tripId=' . $departure['tripId']
. '?hafasTripId=' . $departure['tripId']
. '&lineName=' . $departure['line']['name']
. '&start=' . $departure['stop']['id'],
);
Expand Down

0 comments on commit e75e368

Please sign in to comment.