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

Show correctly the values of hash and none type on stats tab #1838

Merged
merged 1 commit into from
Dec 28, 2022

Conversation

mishina2228
Copy link
Contributor

The keys and values of Redis can be checked in Resque Stats tab.
resque-scheduler registers hash type value on Redis for persistent schedules data.
However, when I try to display the value, it raises an error.

  • persistent_schedules is a hash. Its size is not shown.
    before_stats1
  • Error after clicking the key
    before_stats2

This PR will solve this problem.

  • persistent_schedules' size is shown.
    after_stats1
  • After clicking, we can see the value.
    after_stats2

In addition, this PR corrected the case where the type is none.
#redis_get_size used to return an empty array([]), but it should return 0 here.

@@ -83,6 +85,8 @@ def redis_get_value_as_array(key, start=0)
case Resque.redis.type(key)
when 'none'
[]
when 'hash'
Resque.redis.hgetall(key).to_a[start..(start + 20)]
Copy link
Contributor Author

@mishina2228 mishina2228 Sep 24, 2022

Choose a reason for hiding this comment

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

HGETALL has a noticeable performance problem when the size of the hash is large.
https://redis.io/commands/hgetall/

Time complexity: O(N) where N is the size of the hash.

We do not expect to use such large hashes in Resque, so I use HGETALL here.

@PatrickTulskie
Copy link
Contributor

@mishina2228 hey just going through things here getting caught up. I know it's been a while, but do you think you can rebase your branch and add a test for your change?

@mishina2228
Copy link
Contributor Author

I'm trying to add tests but it could be tough. 😅
To test the methods in the helpers block, it appears that the code in the block needs to be cut out into a module.
https://stackoverflow.com/questions/2878818/how-can-i-test-helpers-blocks-in-sinatra-using-rspec

@PatrickTulskie
Copy link
Contributor

I'm trying to add tests but it could be tough. sweat_smile To test the methods in the helpers block, it appears that the code in the block needs to be cut out into a module. https://stackoverflow.com/questions/2878818/how-can-i-test-helpers-blocks-in-sinatra-using-rspec

Ah okay maybe not worth it in that case then. I think we should be good as-is.

@PatrickTulskie PatrickTulskie merged commit 2d7abf5 into resque:master Dec 28, 2022
@mishina2228
Copy link
Contributor Author

Thanks! 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants