-
Notifications
You must be signed in to change notification settings - Fork 51
Tally provider occurrences in results #1088
Conversation
API Developer Docs Preview: Updating |
This PR has migrations. Please rebase it before merging to ensure that conflicting migrations are not introduced. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I was able to test this locally and see that keys were added for different queries, but weren't added when I requested page=5
.
== b"1" | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we want to add a test (or would it be easily possible to test) that no results are incremented for page queries > 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tested by the test that verifies that the function isn't called by search_controller.search
if the page is 5. Is there a different approach you would like to take?
@sarayourfriend Can you expand on your instructions for manual testing? |
@stacimc I'm happy to, but can you share which part of the manual testing instructions you're stuck on? I'm not sure what to expand on 😕 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. I was able to figure out how to test and verified that the occurrences
and appeared_in_searches
tallies were increased as expected, and not for pages > 4.
For what it's worth, I wasn't clear how to test in Redis. I looked for other PRs involving similar testing and first tried exec'ing into the container with docker-compose exec cache redis-cli
, but then the given SCAN command threw syntax errors. I'm not sure if I was missing steps or if you meant a different command.
To get it working in just ipython
I did:
> import django_redis
> tallies = django_redis.get_redis_connection("tallies")
# Get the keys
> tallies.keys("provider*")
# Probably an easier way to do this, but individually check the value of relevant keys after making searches at http://localhost:50280/v1/images
> tallies.get('provider_appeared_in_searches:image:2023-01-23:flickr')
(and so on)
Sorry, I left out the Testing using ipython is easier and as you did, can follow the code as an example. |
No worries. I looked at that exact documentation when debugging the syntax error 😅 I needed to add Before that FWIW I also initially tried running |
Ah, yes, that would be the issue. Later I will open an issue to add more documentation for how to read from redis in development 👍 |
This reverts commit 59e8569.
fb77e44
to
1bfb7a5
Compare
Fixes
Fixes #1084 by @sarayourfriend
Also fixes #1072 by @AetherUnbound
Description
Tallies provider occurrences in Redis. Disambiguates by week (via a Monday date-stamp shared for all days of a given week), index, and provider.
Only tallies the first four pages.
Testing Instructions
Check out the new unit tests.
For manual testing: run the application with the instructions from the README (you will need to rebuild web if you already have it for the new test dependency, btw).
Then, make a search. Open up a redis connection (
redis-cli
or use a Redis connection fromdjango_redis
injust ipython
) and executeSCAN 0 'provider*'
. You should see the new tallies appear. You can use the keys that you get back from SCAN to view the individual results.Checklist
Update index.md
).main
) ora parent feature branch.
errors.
Developer Certificate of Origin
Developer Certificate of Origin