Giter VIP home page Giter VIP logo

Comments (5)

Earlopain avatar Earlopain commented on July 29, 2024 1

@JeremiahChurch I don't think the dependency on active_support is needed. each_slice should do the job just as well.

from sidekiq-unique-jobs.

mhenrixon avatar mhenrixon commented on July 29, 2024 1

@JeremiahChurch I don't think the dependency on active_support is needed. each_slice should do the job just as well.

Great suggestion, I'll have a look at that.

from sidekiq-unique-jobs.

JeremiahChurch avatar JeremiahChurch commented on July 29, 2024

It looks like the result of digests[1].map in Digests#page has changed because the underlying values are stored/returned differently and that is causing the multiple rows to be returned - the 'blank' is just the time for the lock

    def page(cursor: 0, pattern: SCAN_PATTERN, page_size: 100)
      redis do |conn|
        total_size, digests = conn.multi do |pipeline|
          pipeline.zcard(key)
          pipeline.zscan(key, cursor, match: pattern, count: page_size)
        end
        puts "\n\ndigests: #{digests[1].inspect}\n\n"
        # NOTE: When debugging, check the last item in the returned array.
        [
          total_size.to_i,
          digests[0].to_i, # next_cursor
          digests[1].map { |digest, score| Lock.new(digest, time: score) }, # entries
        ]
      end

returns

digests: ["0", 
["prod_unique_jobs:2e3f377528bd7e5dafca80f993144d81", "1678393091.0208826", 
"prod_unique_jobs:94f085827423f76b1f3e610bf316ad1c", "1678393399.1548831"]
]

when instead it should be nested more like:

digests: ["0", 
[
["prod_unique_jobs:2e3f377528bd7e5dafca80f993144d81", "1678393091.0208826"], 
["prod_unique_jobs:94f085827423f76b1f3e610bf316ad1c", "1678393399.1548831"]
]
]

a monkey patch to use activesupport's in_groups_of(2) gets the page looking good without my changes in #762

module SidekiqUniqueJobs
  class Digests
    def page(cursor: 0, pattern: SCAN_PATTERN, page_size: 100)
      redis do |conn|
        total_size, digests = conn.multi do |pipeline|
          pipeline.zcard(key)
          pipeline.zscan(key, cursor, match: pattern, count: page_size)
        end

        # NOTE: When debugging, check the last item in the returned array.
        [
          total_size.to_i,
          digests[0].to_i, # next_cursor
          digests[1].in_groups_of(2).map { |digest, score| Lock.new(digest, time: score) }, # entries
        ]
      end
    end
  end
end

from sidekiq-unique-jobs.

mhenrixon avatar mhenrixon commented on July 29, 2024

Can I close this then @JeremiahChurch?

from sidekiq-unique-jobs.

JeremiahChurch avatar JeremiahChurch commented on July 29, 2024

Can I close this then @JeremiahChurch?

@mhenrixon without that monkey patch the locks page is still broken. I'm assuming it should generally be fixed?

As-is on 8.0.2 without that patch you'll see

image

with the monkey patch the 'extra' lines are gone

image

If you're alright with active support as a depend I'll pull a PR together if you'd like?

from sidekiq-unique-jobs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.