sidekiq-belt 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: 311732e41366c1a1737b160f74364c13e76015f731191ee0cbd34af81b80afd2
4
- data.tar.gz: 120418dea454eec7c1c9e47d35ad64d823a478d761accc9b9a6b28505e046e3b
3
+ metadata.gz: c5e4649a97ccde536e22d2449ec678ccde0b955c0788c223fecd16487e7e9880
4
+ data.tar.gz: 690b2b57d00bba771275d7143c2104f9b139fc2b883600bf4a95bfbd8b6591b5
5
5
  SHA512:
6
- metadata.gz: 32111af8a8f7f4325f4dee59864eb8bcf0469747663dcdab7f0c5bdb5ec7636526f44447e1914b7cd7cce5b3ad60957c66b6fa52ff5fc2ad4549c78c81723ee2
7
- data.tar.gz: bf61e75d9ca7875ee303726765c323074dfe3f2d76e35ab725cfb51f308a56fbb1fc902a1ce1ae065770ae1e98f88ada773eab0809712ffdb543b9b082146c31
6
+ metadata.gz: dd3e644e8fb40e12809cd5de2744640a46df7695ad2146d7333ac09a7bcc3460168a23ff891d0e60b54fed06986240242f816f2e344d45fc86ead4c9399e350b
7
+ data.tar.gz: 61dc37a8dd5f5e3b29d7410275b3c2776063ac6e2944a72b01619cbb713e8c24d55dbf21c301781865cc9b8b030d7278d1e521e115742b1d6938fc103d65d377
data/CHANGELOG.md CHANGED
@@ -1,9 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.2.0] - 2023-10-07
3
+ ## [0.3.1] - 2023-11-01
4
+
5
+ - Added style to pause button
6
+
7
+ ## [0.3.0] - 2023-10-28
8
+
9
+ - Feature to add button to remove failed batches
10
+
11
+ ## [0.2.0] - 2023-10-14
4
12
 
5
13
  - Feature to Pause/Unpause Periodic Jobs
6
14
 
7
- ## [0.1.0] - 2023-10-07
15
+ ## [0.1.0] - 2023-10-12
8
16
 
9
17
  - Feature to run manualy Periodic Jobs
data/README.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Sidekiq::Belt
2
2
 
3
+
4
+ <a href='http://badge.fury.io/rb/sidekiq-belt'>
5
+ <img src="https://badge.fury.io/rb/sidekiq-belt.png" alt="Gem Version" />
6
+ </a>
7
+ <a href='https://github.com/dannnylo/sidekiq-belt/workflows/CI/badge.svg'>
8
+ <img src="https://github.com/dannnylo/sidekiq-belt/workflows/CI/badge.svg" alt="Build Status" />
9
+ </a>
10
+
3
11
  This Ruby gem enhances the capabilities of Sidekiq, Sidekiq Pro, and Sidekiq Enterprise by adding essential utilities.
4
12
 
5
13
  ## Installation
@@ -59,14 +67,19 @@ To enable this feature, pass the `periodic_pause` option:
59
67
  ```ruby
60
68
  Sidekiq::Belt.use!([:periodic_pause])
61
69
  ```
70
+ ![periodic_pause](https://github.com/dannnylo/sidekiq-belt/assets/20794/41fbcee4-9c5b-45cd-b6f7-c359a22f3979)
71
+ ![periodic_unpause](https://github.com/dannnylo/sidekiq-belt/assets/20794/ea06ae37-068e-4f66-ab10-d83970545a59)
62
72
 
63
73
  ### Delete an Unfinished Batch (sidekiq-pro)
64
74
 
65
- This feature is not yet implemented.
75
+ This option adds a button to remove failed batches.
66
76
 
67
- ### Delete a not finished Batch (sidekiq-pro)
77
+ To enable this feature, pass the `failed_batch_remove` option:
78
+ ```ruby
79
+ Sidekiq::Belt.use!([:failed_batch_remove])
80
+ ```
81
+ ![failed_batch_remove](https://github.com/dannnylo/sidekiq-belt/assets/20794/e285a8b2-4626-48e1-b04a-5190ae51d43b)
68
82
 
69
- It will be implemented in upcoming versions.
70
83
 
71
84
  ## Development
72
85
 
@@ -10,6 +10,8 @@ module Sidekiq
10
10
  def self.use!(_options = [:all])
11
11
  # all = options.include?(:all)
12
12
  # Sidekiq::Belt::Pro::Feature.load! if all || options.include?(:feature)
13
+
14
+ true
13
15
  end
14
16
  end
15
17
  end
@@ -16,6 +16,8 @@ module Sidekiq
16
16
 
17
17
  Sidekiq::Belt::Ent::PeriodicPause.use! if all || options.include?(:periodic_pause)
18
18
  Sidekiq::Belt::Ent::PeriodicRun.use! if all || options.include?(:periodic_run)
19
+
20
+ true
19
21
  end
20
22
  end
21
23
  end
@@ -22,7 +22,7 @@ module Sidekiq
22
22
  PAUSE_BUTTON = <<~ERB
23
23
  <form action="<%= root_path %>loops/<%= loup.lid %>/pause" method="post">
24
24
  <%= csrf_tag %>
25
- <input class="btn btn-danger" type="submit" name="pause" value="<%= t('Pause') %>"
25
+ <input class="btn btn-danger btn-pause" type="submit" name="pause" value="<%= t('Pause') %>"
26
26
  data-confirm="Pause the job <%= loup.klass %>? <%= t('AreYouSure') %>" />
27
27
  </form>
28
28
  ERB
@@ -30,13 +30,25 @@ module Sidekiq
30
30
  UNPAUSE_BUTTON = <<~ERB
31
31
  <form action="<%= root_path %>loops/<%= loup.lid %>/unpause" method="post">
32
32
  <%= csrf_tag %>
33
- <input class="btn btn-danger" type="submit" name="pause" value="<%= t('Unpause') %>"
33
+ <input class="btn btn-danger btn-unpause" type="submit" name="pause" value="<%= t('Unpause') %>"
34
34
  data-confirm="Unpause the job <%= loup.klass %>? <%= t('AreYouSure') %>" />
35
35
  </form>
36
36
  ERB
37
37
 
38
38
  def self.registered(app)
39
39
  app.replace_content("/loops") do |content|
40
+ content.gsub!("</header>", "</header>
41
+ <style>
42
+ .btn-unpause {
43
+ color: #000;
44
+ background-image: none;
45
+ background-color: #ddd;
46
+ }
47
+ .btn-unpause:hover {
48
+ border: 1px solid;
49
+ }
50
+ </style>")
51
+
40
52
  # Add the top of the table
41
53
  content.gsub!("</th>\n </tr>", "</th><th><%= t('Pause/Unpause') %></th></th>\n </tr>")
42
54
 
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sidekiq/web/helpers"
4
+
5
+ module Sidekiq
6
+ module Belt
7
+ module Pro
8
+ module FailedBatchRemove
9
+ module SidekiqFailedBatchRemove
10
+ REMOVE_BUTTON = <<~ERB
11
+ <form action="<%= root_path %>batches/<%= bid %>/remove" method="post">
12
+ <%= csrf_tag %>
13
+ <input class="btn btn-danger" type="submit" name="remove" value="<%= t('Remove') %>"
14
+ data-confirm="Do you want to remove batch <%= bid %>? <%= t('AreYouSure') %>" />
15
+ </form>
16
+ ERB
17
+
18
+ def self.registered(app)
19
+ app.replace_content("/batches") do |content|
20
+ content.gsub!("</th>\n <%", "</th><th><%= t('Delete') %></th>\n <%")
21
+
22
+ content.gsub!(
23
+ "</td>\n </tr>\n <% end %>",
24
+ "</td>\n<td>#{REMOVE_BUTTON}</td>\n </tr>\n <% end %>"
25
+ )
26
+ end
27
+
28
+ app.post("/batches/:bid/remove") do
29
+ Sidekiq::Batch::Status.new(params[:bid]).delete
30
+
31
+ return redirect "#{root_path}batches"
32
+ end
33
+ end
34
+ end
35
+
36
+ def self.use!
37
+ require("sidekiq/web")
38
+
39
+ Sidekiq::Web.register(Sidekiq::Belt::Pro::FailedBatchRemove::SidekiqFailedBatchRemove)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -2,18 +2,20 @@
2
2
 
3
3
  require "sidekiq"
4
4
 
5
- # require_relative "feature"
5
+ require_relative "failed_batch_remove"
6
6
 
7
7
  module Sidekiq
8
8
  module Belt
9
9
  module Pro
10
10
  module Files
11
- def self.use!(_options = [:all])
11
+ def self.use!(options = [:all])
12
12
  return unless Sidekiq.pro?
13
13
 
14
+ all = options.include?(:all)
15
+
16
+ Sidekiq::Belt::Pro::FailedBatchRemove.use! if all || options.include?(:failed_batch_remove)
17
+
14
18
  true
15
- # all = options.include?(:all)
16
- # Sidekiq::Belt::Pro::Feature.load! if all || options.include?(:feature)
17
19
  end
18
20
  end
19
21
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Belt
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
@@ -5,10 +5,6 @@ require "sidekiq/web/action"
5
5
 
6
6
  module Sidekiq
7
7
  module WebActionHelper
8
- def self.blocks
9
- @blocks ||= {}
10
- end
11
-
12
8
  def render(engine, content, options = {})
13
9
  begin
14
10
  path_info = /"([^"]*)"/.match(block.source.to_s)[1]
@@ -18,7 +14,7 @@ module Sidekiq
18
14
 
19
15
  path_info ||= ::Rack::Utils.unescape(env["PATH_INFO"])
20
16
 
21
- Sidekiq::WebActionHelper.blocks.fetch(path_info.to_s, []).each do |content_block|
17
+ Sidekiq::Config::DEFAULTS[:replace_views].fetch(path_info.to_s, []).each do |content_block|
22
18
  content_block.call(content)
23
19
  end
24
20
 
@@ -7,8 +7,9 @@ require_relative "web_action_helper"
7
7
  module Sidekiq
8
8
  module WebRouterHelper
9
9
  def replace_content(path, &block)
10
- Sidekiq::WebActionHelper.blocks[path.to_s] ||= []
11
- Sidekiq::WebActionHelper.blocks[path.to_s] << block
10
+ Sidekiq::Config::DEFAULTS[:replace_views] ||= {}
11
+ Sidekiq::Config::DEFAULTS[:replace_views][path.to_s] ||= []
12
+ Sidekiq::Config::DEFAULTS[:replace_views][path.to_s] << block
12
13
  end
13
14
  end
14
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Jeremias da Silva
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-14 00:00:00.000000000 Z
11
+ date: 2023-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
19
+ version: 7.1.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">"
25
25
  - !ruby/object:Gem::Version
26
- version: '7.0'
26
+ version: 7.1.4
27
27
  description: This Ruby gem enhances the capabilities of Sidekiq, Sidekiq Pro, and
28
28
  Sidekiq Enterprise by adding essential utilities.
29
29
  email:
@@ -45,6 +45,7 @@ files:
45
45
  - lib/sidekiq/belt/ent/files.rb
46
46
  - lib/sidekiq/belt/ent/periodic_pause.rb
47
47
  - lib/sidekiq/belt/ent/periodic_run.rb
48
+ - lib/sidekiq/belt/pro/failed_batch_remove.rb
48
49
  - lib/sidekiq/belt/pro/files.rb
49
50
  - lib/sidekiq/belt/version.rb
50
51
  - lib/sidekiq/web_action_helper.rb