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

Hardcoded rate limit value leads to slow tests #4427

Open
gravitystorm opened this issue Dec 20, 2023 · 0 comments
Open

Hardcoded rate limit value leads to slow tests #4427

gravitystorm opened this issue Dec 20, 2023 · 0 comments
Labels
dx Developer Experience refactor Refactoring, or things that work but could be done better

Comments

@gravitystorm
Copy link
Collaborator

In the calculation for the changeset_comments rate limit, there is a hardcoded value of "200" for deciding if a user is experienced or not.

previous_comments = changeset_comments.limit(200).count

This has to be matched by the same hardcoded value in the tests

create_list(:changeset_comment, 200, :author_id => user.id, :created_at => Time.now.utc - 1.day)

However, creating 200 dummy changeset comments can take a few seconds. It would be a nice-to-have to allow this value to be overridden, and a lower (faster) value to be used in the test suite. Reducing the value from 200 to 20 reduces that test from 5.6 to 1.6 seconds on my machine.

It's also a good idea to avoid magic numbers in the code anyway. It took me a while to figure that the number in the test suite was a specific number, and not just "some arbitrary large number".

@gravitystorm gravitystorm added refactor Refactoring, or things that work but could be done better dx Developer Experience labels Dec 20, 2023
GobinathAL added a commit to GobinathAL/openstreetmap-website that referenced this issue Jan 8, 2024
This value is the minimum number of changeset comments required to get
Settings.max_changeset_comments_per_hour
GobinathAL added a commit to GobinathAL/openstreetmap-website that referenced this issue Jan 8, 2024
This value is the minimum number of changeset comments required to get
Settings.max_changeset_comments_per_hour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dx Developer Experience refactor Refactoring, or things that work but could be done better
Projects
None yet
Development

No branches or pull requests

1 participant