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

Proposal: remove attemptContext #949

Open
sspenst opened this issue Jul 16, 2023 · 0 comments
Open

Proposal: remove attemptContext #949

sspenst opened this issue Jul 16, 2023 · 0 comments
Labels
question Further information is requested refactor Improving or cleaning up existing code

Comments

@sspenst
Copy link
Owner

sspenst commented Jul 16, 2023

Motivation

There have been many bugs related to playattempts, and they are always very complex to debug. Even after resolving many bugs and polishing the APIs, the logic is still difficult to understand. Playattempt bugs have almost always been caused by the existence of attemptContext (playattempts are out of order, time range overlap because of extending the wrong playattempt, etc).

Additionally, 30% of the existing playattempt documents have attemptContext BEATEN with identical startTime and endTime, meaning there is a large amount of useless data stored due to attemptContext.

Proposal

Remove attemptContext from playattempts and instead use the ts field from statmodel to calculate play time. startTime and endTime can probably even be removed from playattempts and instead be automatically handled by createdAt and updatedAt (incrementing updateCount will set updatedAt).

Although this makes playattempts simpler and avoids possible bugs, it makes queries related to total play time more difficult. Instead of calculating endTime - startTime for all non-BEATEN playattempts, you'll have to find all playattempts where startTime < level completion time, and make sure to cut any playattempts that cross over a level completion time.

@sspenst sspenst added question Further information is requested refactor Improving or cleaning up existing code labels Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested refactor Improving or cleaning up existing code
Projects
None yet
Development

No branches or pull requests

1 participant