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

Include custom beatmap tags set by own user in response #11951

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

notbakaneko
Copy link
Collaborator

@notbakaneko notbakaneko commented Feb 28, 2025

  • shouldn't query every beatmap separately

@notbakaneko notbakaneko marked this pull request as ready for review February 28, 2025 09:20
@@ -396,6 +398,7 @@ private function showJson($beatmapset)
"{$beatmapRelation}.baseMaxCombo",
"{$beatmapRelation}.failtimes",
"{$beatmapRelation}.beatmapOwners.user",
"{$beatmapRelation}.ownBeatmapTags" => fn ($q) => $user !== null ? $q->where('user_id', $user->getKey()) : $q->none(),
Copy link
Collaborator

@nanaya nanaya Feb 28, 2025

Choose a reason for hiding this comment

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

so this kinda works but I don't know if better 🤔 less fake ownBeatmapTags at least, and maybe call it current_user_tag_ids and always use Auth::user() in the scope.

Or maybe JSON_OBJECTAGG($userId, JSON_ARRAYAGG(...)) and pass the current user all the way again.

public function scopeWithUserTagIds($query, $userId)
{
    if ($userId === null) {
        $tagQuery = \DB::query()->selectRaw('null');
    } else {
        $tagQuery = BeatmapTag
            ::where('user_id', $userId)
            ->whereColumn('beatmap_id', $this->qualifyColumn('beatmap_id'));
        $tagQuery->selectRaw("GROUP_CONCAT({$tagQuery->qualifyColumn('tag_id')} SEPARATOR ',')");
    }

    return $query->addSelect(['user_tag_ids' => $tagQuery]);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants