resque-disable-job 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acc1e95ce6c23efb0f9a1f6e4f83dbc4c791ff89
4
- data.tar.gz: 1058c2273ec04f487a0f89a44f6cd82aa4fa95ac
3
+ metadata.gz: 4e5443eca7a655fcfe205105c1db550c43bb9f32
4
+ data.tar.gz: f27ded11981d8260271c23788319f184bae52932
5
5
  SHA512:
6
- metadata.gz: fe0543e6cecac2551a46e9b9634c47672cfc74617626ab3cf0365bc3b263f0c22d0c4033e9b5ef6940afd657f17e88b193abacb1bc359963551dbf541b80f81a
7
- data.tar.gz: bf8a921179b2f961879bab400f1a2ccde087a9233cf266ded058ffa968f0fec50164fbbfebe15ffd470cd6efe2519118df86a641869cd3c9b9515efd4b74a1c9
6
+ metadata.gz: e5e0ba4713b9a816863e93c7f2f98a74eb5c1a27243e7ddf6eba1ceae60012b67a4e47594406a3db21f07717514e7088d5d540345131194ab26c4e21a04d29df
7
+ data.tar.gz: 3183fc7f2f292dce6eacfe2cf13649bce1ed74a41a2b3e26eb1a59dd6c5045d3afe25d79e25ea4afe82811024514a8134524fa1a524f07fe156422626c36e414
data/.gitignore CHANGED
@@ -13,3 +13,6 @@
13
13
  Gemfile.lock
14
14
  .ruby-version
15
15
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
16
+
17
+ # Exclude the built gems
18
+ *.gem
data/README.md CHANGED
@@ -42,9 +42,9 @@ By default this will just raise `Resque::Job::DontPerform`. If you want to do mo
42
42
 
43
43
  ### Disabling a Job
44
44
 
45
- In your application's console you can use the `Resque::Plugins::DisableJob.disable_job` method to disable a job.
45
+ In your application's console you can use the `Resque::Plugins::DisableJob::Job.disable_job` method to disable a job.
46
46
 
47
- `Resque::Plugins::DisableJob.disable_job(job_name, matching_arguments, ttl = 3600)`
47
+ `Resque::Plugins::DisableJob::Job.disable_job(job_name, matching_arguments, ttl = 3600)`
48
48
 
49
49
  Note: By default, each rule has a ttl of 1 hour. This is because disabling a job should be a temporary action.
50
50
 
@@ -74,11 +74,12 @@ Resque::Plugins::DisableJob::Job.enable_all!
74
74
 
75
75
  ### Operations
76
76
 
77
- `Resque::Plugins::DisableJob::Stats` comes with a a few methods that will help you keep track of actively disabled jobs and how many times the rule was matched.
77
+ `Resque::Plugins::DisableJob::Stats` comes with a a few methods that will help you keep track of actively disabled jobs and how many times the rule was matched.
78
+ They all return an `Array[Resque::Plugins::DisableJob::Rule]`.
78
79
 
79
- * `all_disabled_jobs` - returns a hash of all the disabled jobs and their rules
80
- * `job_disabled_rules(job_name)` - returns a hash of all the rules for one particular job
81
- * `disabled_stats` - returns an array of all the disabled jobs, their rules, and the counter of how many times it was matched
80
+ * `all_disabled_jobs` - a list of all the disabled jobs and their rules
81
+ * `job_disabled_rules(job_name)` - a list of all the rules for one particular job
82
+ * `disabled_stats` - all the disabled jobs, their rules, and the counter of how many times it was matched (the `Rule` objects have the `counter` attribute set)
82
83
 
83
84
  ## Development
84
85
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Resque
4
4
  module DisableJob
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
@@ -22,6 +22,7 @@ module Resque
22
22
  class Rule
23
23
  JOBS_SET = 'disabled_jobs'
24
24
  attr_reader :job_name
25
+ attr_accessor :count
25
26
 
26
27
  def initialize(job_name, arguments = [], digest = '')
27
28
  @job_name = job_name
@@ -9,25 +9,20 @@ module Resque
9
9
  # These are methods that inspect the rules
10
10
  class Stats
11
11
  def self.all_disabled_jobs
12
- Hash[Job.disabled_jobs.map { |name| [name, job_disabled_rules(name)] }]
12
+ Job.disabled_jobs.map { |name| job_disabled_rules(name) }.flatten
13
13
  end
14
14
 
15
15
  def self.job_disabled_rules(name)
16
- Resque.redis.hgetall(Rule.new(name).all_rules_key)
16
+ Resque.redis.hgetall(Rule.new(name).all_rules_key).each_with_object([]) do |(digest, arguments), rules|
17
+ rules << Rule.new(name, arguments, digest)
18
+ end
17
19
  end
18
20
 
19
21
  def self.disabled_stats
20
- counts = all_disabled_jobs.map do |name, rules|
21
- rules.map do |digest, arguments|
22
- {
23
- job_name: name,
24
- digest: digest,
25
- arguments: arguments,
26
- count: Resque.redis.get(Rule.new(name, arguments, digest).rule_key)
27
- }
28
- end
22
+ all_disabled_jobs.map do |rule|
23
+ rule.count = Resque.redis.get(rule.rule_key).to_i
24
+ rule
29
25
  end
30
- counts.flatten
31
26
  end
32
27
  end
33
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-disable-job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Balcanasu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-08 00:00:00.000000000 Z
11
+ date: 2017-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque