Skip to content

AO3 4581 cache the counts in the wrangling sidebar. #2472

Merged
merged 3 commits into from Jun 6, 2016

4 participants

zz9pzza added some commits May 30, 2016
@zz9pzza zz9pzza Inital try at caching counts in wrangling sidebar 06ca211
@zz9pzza zz9pzza Flush the cache in the tests
644605e
@houndci-bot houndci-bot commented on the diff May 30, 2016
features/step_definitions/tag_set_steps.rb
+end
+
+When(/^I flush the wrangling sidebar caches$/) do
+ [Fandom, Character, Relationship, Freeform].each do |klass|
@houndci-bot
houndci-bot added a note May 30, 2016

Redundant use of Object#to_s in interpolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 30, 2016
app/controllers/tag_wranglers_controller.rb
@@ -38,7 +38,9 @@ def show
@fandoms = @wrangler.fandoms.by_name
@counts = {}
[Fandom, Character, Relationship, Freeform].each do |klass|
- @counts[klass.to_s.downcase.pluralize.to_sym] = klass.unwrangled.in_use.count
+ @counts[klass.to_s.downcase.pluralize.to_sym] = Rails.cache.fetch("/wrangler/counts/sidebar/#{klass.to_s}", race_condition_ttl: 10, expires_in: 1.hour) do
@houndci-bot
houndci-bot added a note May 30, 2016

Redundant use of Object#to_s in interpolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@zz9pzza zz9pzza Listen to the hound
9f83a8b
@CristinaRO
Organization for Transformative Works member

Question for clarification: is this the kind of cache that only expires when the expiration time kicks in? So, in this case, the cached count will only expire every hour for each category?

@zz9pzza
zz9pzza commented May 31, 2016

That is correct it will only expire after an hour, The tag wrangling chairs were happy to accept two hours and willing to accept 12 hours.

@CristinaRO
Organization for Transformative Works member

If @LadyOscar has pre-emptively given her 🐹 of approval, this can go in.

@zz9pzza zz9pzza merged commit 303dc1d into otwcode:master Jun 6, 2016

2 checks passed

Details continuous-integration/travis-ci/pr The Travis CI build passed
hound No violations found. Woof!
@sarken sarken commented on the diff Jun 8, 2016
features/step_definitions/tag_set_steps.rb
+end
+
+When(/^I flush the wrangling sidebar caches$/) do
@sarken
Organization for Transformative Works member
sarken added a note Jun 8, 2016

This issue appears to be broken on test. When you submit a fix for it, can you please move this step definition into the proper file? Right now it's in the tag set steps, but it's not related to tag sets -- it should be in https://github.com/otwcode/otwarchive/blob/master/features/step_definitions/tag_steps.rb, which is where wrangling stuff lives. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.