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

Fix pack pass check considering converted plays when pack is not associated with a ruleset #277

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Sep 6, 2024

Reported privately.

The corresponding web-10 query looks like this (somewhat abridged):

SELECT COUNT(*) FROM (
SELECT p.beatmapset_id FROM osu_beatmappacks_items p JOIN osu_beatmaps b USING (beatmapset_id) JOIN osu_scores_high s USING (beatmap_id) WHERE s.user_id = @userId AND b.playmode = 0 AND pack_id = @packId UNION DISTINCT
SELECT p.beatmapset_id FROM osu_beatmappacks_items p JOIN osu_beatmaps b USING (beatmapset_id) JOIN osu_scores_taiko_high s USING (beatmap_id) WHERE s.user_id = @userId AND b.playmode = 1 AND pack_id = @packId UNION DISTINCT
SELECT p.beatmapset_id FROM osu_beatmappacks_items p JOIN osu_beatmaps b USING (beatmapset_id) JOIN osu_scores_fruits_high s USING (beatmap_id) WHERE s.user_id = @userId AND b.playmode = 2 AND pack_id = @packId UNION DISTINCT
SELECT p.beatmapset_id FROM osu_beatmappacks_items p JOIN osu_beatmaps b USING (beatmapset_id) JOIN osu_scores_mania_high s USING (beatmap_id) WHERE s.user_id =  @userId} AND b.playmode = 3 AND pack_id = @packId) a

If it is not immediately clear why the above disallows converts, then to spell it out: it is the part that the query is split into four UNION'd parts, each of which queries only one scores_high table for each of the rulesets, and only includes the beatmaps in the pack which have the same playmode.

For profiling purposes, here are two examples of query shapes after this change, taken from the test (params may need tweaking appropriately):

SELECT COUNT(distinct p.beatmapset_id)
FROM osu_beatmappacks_items p
JOIN osu_beatmaps b USING (beatmapset_id)
JOIN scores s USING (beatmap_id)
WHERE s.user_id = 2 AND s.passed = 1 AND s.preserve = 1 AND pack_id = 40 AND `s`.`ruleset_id` = `b`.`playmode`
SELECT COUNT(distinct p.beatmapset_id)
FROM osu_beatmappacks_items p
JOIN osu_beatmaps b USING (beatmapset_id)
JOIN scores s USING (beatmap_id)
WHERE s.user_id = 2 AND s.passed = 1 AND s.preserve = 1 AND pack_id = 2036 AND `s`.`ruleset_id` = `b`.`playmode`
AND json_search(data, 'one', 'EZ', null, '$.mods[*].acronym') IS NULL
AND json_search(data, 'one', 'NF', null, '$.mods[*].acronym') IS NULL
AND json_search(data, 'one', 'HT', null, '$.mods[*].acronym') IS NULL
AND json_search(data, 'one', 'DC', null, '$.mods[*].acronym') IS NULL
AND json_search(data, 'one', 'SO', null, '$.mods[*].acronym') IS NULL
AND s.pp IS NOT NULL

…ciated with a ruleset

Reported privately.

The corresponding web-10 query looks like this (somewhat abridged):

	SELECT COUNT(*) FROM (
        SELECT p.beatmapset_id FROM osu_beatmappacks_items p JOIN osu_beatmaps b USING (beatmapset_id) JOIN osu_scores_high s USING (beatmap_id) WHERE s.user_id = userId AND b.playmode = 0 AND pack_id = packId UNION DISTINCT
        SELECT p.beatmapset_id FROM osu_beatmappacks_items p JOIN osu_beatmaps b USING (beatmapset_id) JOIN osu_scores_taiko_high s USING (beatmap_id) WHERE s.user_id = userId AND b.playmode = 1 AND pack_id = packId UNION DISTINCT
        SELECT p.beatmapset_id FROM osu_beatmappacks_items p JOIN osu_beatmaps b USING (beatmapset_id) JOIN osu_scores_fruits_high s USING (beatmap_id) WHERE s.user_id = userId AND b.playmode = 2 AND pack_id = packId UNION DISTINCT
        SELECT p.beatmapset_id FROM osu_beatmappacks_items p JOIN osu_beatmaps b USING (beatmapset_id) JOIN osu_scores_mania_high s USING (beatmap_id) WHERE s.user_id =  userId} AND b.playmode = 3 AND pack_id = packId) a

If it is not immediately clear why the above disallows converts, then to
spell it out: it is the part that the query is split into four
`UNION`'d parts, each of which queries only one `scores_high` table for
each of the rulesets, and only includes the beatmaps in the pack which
have the same `playmode`.

For profiling purposes, here are two examples of query shapes after this
change, taken from the test:

	SELECT COUNT(distinct p.beatmapset_id)
	FROM osu_beatmappacks_items p
	JOIN osu_beatmaps b USING (beatmapset_id)
	JOIN scores s USING (beatmap_id)
	WHERE s.user_id = 2 AND s.passed = 1 AND s.preserve = 1 AND pack_id = 40 AND `s`.`ruleset_id` = `b`.`playmode`

	SELECT COUNT(distinct p.beatmapset_id)
	FROM osu_beatmappacks_items p
	JOIN osu_beatmaps b USING (beatmapset_id)
	JOIN scores s USING (beatmap_id)
	WHERE s.user_id = 2 AND s.passed = 1 AND s.preserve = 1 AND pack_id = 2036 AND `s`.`ruleset_id` = `b`.`playmode`
	AND json_search(data, 'one', 'EZ', null, '$.mods[*].acronym') IS NULL
	AND json_search(data, 'one', 'NF', null, '$.mods[*].acronym') IS NULL
	AND json_search(data, 'one', 'HT', null, '$.mods[*].acronym') IS NULL
	AND json_search(data, 'one', 'DC', null, '$.mods[*].acronym') IS NULL
	AND json_search(data, 'one', 'SO', null, '$.mods[*].acronym') IS NULL
	AND s.pp IS NOT NULL
@bdach bdach force-pushed the fix-non-ruleset-packs-including-converts branch from e303448 to 6b66e9e Compare September 6, 2024 09:47
@peppy peppy self-requested a review September 9, 2024 05:57
@peppy peppy merged commit ff7f268 into ppy:master Sep 9, 2024
3 checks passed
@bdach bdach deleted the fix-non-ruleset-packs-including-converts branch September 11, 2024 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants