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

Add command for applying simple mod multiplier changes #246

Closed
wants to merge 7 commits into from

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Mar 27, 2024

Opening as draft because while this works, this is the absolute simplest tool for the job at hand (namely, changing classic mod multiplier). Its limitations are:

  • Adjusting multipliers on the same scores many times is going to cause precision loss due to rounding.
  • This command only works if the multiplier for a mod is not dependent on its settings, ie. it will not work for something like half/double time.

If the properties above are desired now, then my proposal is to split this command into two.

  • The first will unapply the mod multiplier for every score out there and store that raw value somewhere. I propose that "somewhere" to be the data json blob, because it doesn't require costly schema changes to execute.
  • The second command will re-apply the multiplier for every score out there by taking raw score from the json blob, deserialising the mods and the total score from it, and using lazer code to retroactively compute the mod multiplier. It'll resemble the verify command but for mod multipliers.

+ "FROM `scores` "
+ "WHERE `id` BETWEEN @lastId AND (@lastId + @batchSize - 1) "
+ "AND `ruleset_id` = @rulesetId "
+ "AND JSON_SEARCH(`data`, 'one', @modAcronym, NULL, '$.mods[*].acronym') IS NOT NULL",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wasn't sure whether to do this sql-side or c#-side. I think this should be somewhat painless because EXPLAIN pegs this as a where filter over a range PK lookup so it shouldn't be that slow.

|| OldMultiplier == null
|| NewMultiplier == null)
{
await Console.Error.WriteLineAsync("One or more required parameters is missing.");
Copy link
Member

Choose a reason for hiding this comment

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

Kinda weird to have optional arguments which are required (usually I'd use standard arguments in place of this, but I guess your goal is to have things named?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I didn't want to have them purely positional to prevent screw-ups from swapping them or something.

{
[Command(Name = "score", Description = "Runs batch processing on score totals for scores and users.")]
[Subcommand(typeof(ChangeModMultiplierCommand))]
public class ScoreCommands
Copy link
Member

Choose a reason for hiding this comment

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

I would have probably just put the command in maintenance, given there's already similar score repair commands in there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At the time of writing I wasn't sure if there were going to be any others, for e.g. user total recalculations. But I think it's pretty clear to me that it's not required anymore, will move.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add `Serializable` attribute to suppress CI complaint
@bdach bdach marked this pull request as ready for review April 12, 2024 08:02
@bdach bdach closed this Apr 12, 2024
@bdach bdach deleted the change-mod-multipliers branch April 12, 2024 09:48
@peppy
Copy link
Member

peppy commented Apr 12, 2024

As per discord, not sure why this is close/delete. We will still need this command and the structure likely won't change by much at all. Unless the thought is that we'd run a batch sql (ie. via ASS mass-operate) and then run ES as a separate step after we have total_score_without_mods and therefore it's redaundant?

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.

Add command for applying mod multiplier changes
2 participants