Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧑‍💻 Replace user details by LightUserResource in LeaderboardUserResource #2635

Merged
merged 17 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/Http/Resources/LeaderboardUserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* @OA\Schema(
* title="LeaderboardUserResource",
* @OA\Property(property="id", type="integer", example="1"),
* @OA\Property(property="displayName", type="string", example="Gertrud"),
* @OA\Property(property="username", type="string", description="username of user", example="Gertrud123"),
* @OA\Property(property="profilePicture", type="string", description="URL of the profile picture of the user", example="https://traewelling.de/@Gertrud123/picture"),
* @OA\Property(property="totalDuration", type="integer", description="duration travelled in minutes", example=6),
Expand All @@ -19,7 +21,9 @@ class LeaderboardUserResource extends JsonResource
{
public function toArray($request): array {
return [
'username' => $this->user->username,
'id' => (int) $this->user->id,
'displayName' => (string) $this->user->name,
'username' => (string) $this->user->username,
'profilePicture' => ProfilePictureController::getUrl($this->user),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can include the LightUserResource here. This reduced the amount of different resources with similar attributes.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer my proposed implementation because it fits better into my existing implementation of the user model.

'trainDuration' => (int) $this->duration, // @deprecated: remove after 2024-08
'trainDistance' => (float) $this->distance, // @deprecated: remove after 2024-08
Expand Down
16 changes: 12 additions & 4 deletions storage/api-docs/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"description": "Production Server"
},
{
"url": "http://localhost:8000/api/v1",
"url": "http://localhost:8000/api/v1/api/v1",
MrKrisKrisu marked this conversation as resolved.
Show resolved Hide resolved
"description": "This instance"
}
],
Expand Down Expand Up @@ -4553,6 +4553,14 @@
"LeaderboardUserResource": {
"title": "LeaderboardUserResource",
"properties": {
"id": {
"type": "integer",
"example": "1"
},
"displayName": {
"type": "string",
"example": "Gertrud"
},
"username": {
"description": "username of user",
"type": "string",
Expand Down Expand Up @@ -5944,9 +5952,9 @@
"scheme": "https",
"flows": {
"authorizationCode": {
"authorizationUrl": "http://localhost:8000/oauth/authorize",
"tokenUrl": "http://localhost:8000/oauth/token",
"refreshUrl": "http://localhost:8000/auth/refresh",
"authorizationUrl": "http://localhost:8000/api/v1/oauth/authorize",
"tokenUrl": "http://localhost:8000/api/v1/oauth/token",
"refreshUrl": "http://localhost:8000/api/v1/auth/refresh",
MrKrisKrisu marked this conversation as resolved.
Show resolved Hide resolved
"scopes": {
"read-statuses": "see all statuses",
"read-notifications": "see your notifications",
Expand Down
Loading