Module: SidekiqUniqueJobs::Web

Defined in:
lib/sidekiq_unique_jobs/web.rb,
lib/sidekiq_unique_jobs/web/helpers.rb

Overview

Utility module to help manage unique keys in redis. Useful for deleting keys that for whatever reason wasn’t deleted

Defined Under Namespace

Modules: Helpers

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object

rubocop:disable Metrics/MethodLength



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/sidekiq_unique_jobs/web.rb', line 17

def self.registered(app) # rubocop:disable Metrics/MethodLength
  app.helpers do
    include Web::Helpers
  end

  app.get '/unique_digests' do
    @filter         = params[:filter] || '*'
    @filter         = '*' if @filter == ''
    @count          = (params[:count] || 100).to_i
    @current_cursor = params[:cursor]
    @prev_cursor    = params[:prev_cursor]
    @total_size, @next_cursor, @unique_digests =
      Digests.page(pattern: @filter, cursor: @current_cursor, page_size: @count)

    erb(unique_template(:unique_digests))
  end

  app.get '/unique_digests/:digest' do
    @digest = params[:digest]
    @unique_keys = Util.keys("#{@digest}*", 1000)

    erb(unique_template(:unique_digest))
  end

  app.get '/unique_digests/:digest/delete' do
    Digests.del(digest: params[:digest])
    redirect_to :unique_digests
  end
end