Skip to content

Support multiple mappers on beatmap difficulties #11377

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

Merged
merged 168 commits into from
Dec 5, 2024

Conversation

notbakaneko
Copy link
Collaborator

@notbakaneko notbakaneko commented Jul 30, 2024

closes #7602

Also refactors out the username input/search thing a separate component

  • fix some display consistency things.
  • missing users should still be in response.
  • preserve existing guest mapper even if missing or restricted when updating.
  • user profile page 🤔
  • Refactor username input lookup component #11451
  • search and indexing

@notbakaneko notbakaneko force-pushed the feature/beatmaps-multiple-mappers branch from 2cc68f8 to 8ed9cab Compare December 2, 2024 12:11
);

// TODO: remove when everything writes to beatmap_owners.
if (!$owners->contains(fn ($beatmapOwner) => $beatmapOwner->user_id === $this->user_id) && $this->user !== null) {
Copy link
Collaborator

@nanaya nanaya Dec 3, 2024

Choose a reason for hiding this comment

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

related to the comment above, can't this be simplified to just if ($owners->empty() && $this->user !== null) {?

There should be only these two possibilities, right?

  1. unmigrated/new entry with only ->user_id and no ->beatmapOwners
  2. osu-web managed entry with ->user_id already in ->beatmapOwners

(there's also a potential weird bug/case already existing here - the array should probably always be filled in with at least a deleted user of id ->user_id)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it a simplification if more states have to be considered instead of user is in or not? 🤨

Copy link
Collaborator

Choose a reason for hiding this comment

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

what more state? it's just whether there's anything in it or not

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's also making another unnecessary assumption instead of just user in or not

Copy link
Collaborator

Choose a reason for hiding this comment

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

it skips looping through the array and so the check is way simpler

Copy link
Collaborator

Choose a reason for hiding this comment

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

also I think it's a fine assumption - there's either anything in the owners table or there's none

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's also very pointless bike shedding

Copy link
Collaborator

@nanaya nanaya Dec 4, 2024

Choose a reason for hiding this comment

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

more like optimization instead of bike shedding to me?

also, looking again, it's not an assumption. it's how the system works. the only other case is when user id is not in the owners but that's a broken case and that's where assumption goes (which applies to any way of handling it - be it blindly adding it as owner or just ignoring it)

Copy link
Collaborator

@nanaya nanaya left a comment

Choose a reason for hiding this comment

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

should mostly work... additional fixes can be done later as necessary

private get inputUser() {
return this.props.userByName.get(normaliseUsername(this.inputUsername));
private get canSave() {
return this.validUsers.size > 0 && normaliseUsername(this.inputUsername).length === 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

normaliseUsername is now just a rather verbose way to do a .trim

fn ($beatmapOwner) => $beatmapOwner->user ?? new DeletedUser(['user_id' => $beatmapOwner->user_id])
);

// TODO: remove when everything writes to beatmap_owners.
Copy link
Collaborator

Choose a reason for hiding this comment

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

more like should eventually decide whether an empty collection is acceptable or not (in case of broken owners or just simplifying simple cases)

user: UserJson;
}

function createRemoveOwnerHandler(user: UserJson, onRemoveClick?: NonNullable<Props['onRemoveUser']>) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's no need for this lint workaround anymore now that the component is split out - this can just be part of the component

renderUser={this.renderOwner}
/>
) : (
this.owners.map((owner) => <BeatmapOwner key={owner.id} editing={this.editing} user={owner} />)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this can just call renderUser

@@ -64,6 +66,15 @@ public function inactive(): static
]);
}

public function owner(User $user): static
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should (will?) probably be owners instead


public function __construct(private Beatmap $beatmap, array $newUserIds, private User $source)
{
priv_check_user($source, 'BeatmapUpdateOwner', $beatmap->beatmapset)->ensureCan();
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems like this should be part of controller (as it previously was) as indicated by the need to create additional user in test

@nanaya nanaya enabled auto-merge December 5, 2024 07:35
@nanaya nanaya merged commit a2fe0c5 into ppy:master Dec 5, 2024
3 checks passed
@notbakaneko notbakaneko deleted the feature/beatmaps-multiple-mappers branch December 16, 2024 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow to choose several mappers as difficulty owners
4 participants