active_job_tracker 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -4
- data/app/models/active_job_tracker_record.rb +1 -1
- data/app/views/active_job_tracker/_active_job_tracker_wrapper.html.erb +1 -1
- data/app/views/active_job_tracker/_radial_progress.html.erb +41 -0
- data/lib/active_job_tracker/configuration.rb +5 -0
- data/lib/active_job_tracker/version.rb +1 -1
- data/lib/generators/active_job_tracker/templates/config/initializers/active_job_tracker.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fa0e770ace4f14af8adb0907741243fd3c73e5da3be0ce81c9759ceab1ab06e
|
4
|
+
data.tar.gz: 42121c16e596aabd423ed4899997cdb909e1c61620cbe231a80e1f3674e3059e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a9d3c246ade707d9504a7ca986ee17e0c5db4e4dbd42bd6de360983f631523d589eecc2dd8f5a382e247d0ce2112dc108131e053907f0bf0198b496c7f2fc02
|
7
|
+
data.tar.gz: b844a3cd0174ea768cd07f67e4f8b1e5ac0e4565ef9147335147f90d93df576ad9f2dc4aa2b55287ed1cfb6fe9364e80c2b4c2a99f73968c5686addea38cd77b
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
❤️ I'm looking for a full-time position. Please consider hiring me.
|
2
|
+
|
1
3
|
# ActiveJobTracker
|
2
4
|
|
3
5
|
ActiveJobTracker provides persisted, real-time tracking and monitoring of ActiveJob jobs in Ruby on Rails applications. It allows you to track job status, progress, and errors with a simple API and real-time UI updates via ActionCable.
|
4
6
|
|
5
|
-
<
|
7
|
+
<div align="center">
|
8
|
+
<img width="500" alt="Screenshot 2025-03-04 at 1 09 38 PM" src="https://github.com/user-attachments/assets/d34e6fb8-bb3c-4d71-a737-2f7597a23c43" />
|
9
|
+
</div>
|
6
10
|
|
7
11
|
## Features
|
8
12
|
|
@@ -10,7 +14,7 @@ ActiveJobTracker provides persisted, real-time tracking and monitoring of Active
|
|
10
14
|
- Monitor job progress with percentage completion
|
11
15
|
- Real-time UI updates via ActionCable
|
12
16
|
- Error tracking and reporting
|
13
|
-
- Efficient progress caching to minimize database updates
|
17
|
+
- Efficient progress write-behind caching to minimize database updates
|
14
18
|
- Configurable options
|
15
19
|
|
16
20
|
## Installation
|
@@ -66,6 +70,10 @@ ActiveJobTracker.configure do |config|
|
|
66
70
|
# Whether to include the style in the job tracker (default: true)
|
67
71
|
# When true, the gem's CSS styles are automatically included
|
68
72
|
config.include_style = true
|
73
|
+
|
74
|
+
# Custom Turbo Stream channel name (default: 'active_job_tracker')
|
75
|
+
# Use this to customize the ActionCable channel name for real-time updates
|
76
|
+
config.turbo_stream_channel = 'Turbo::StreamsChannel'
|
69
77
|
end
|
70
78
|
```
|
71
79
|
|
@@ -80,9 +88,9 @@ class CsvUpload < ApplicationRecord
|
|
80
88
|
# Sets up polymorphic association to tie this record to the ActiveJobTracker
|
81
89
|
has_one :job, as: :active_job_trackable, class_name: 'ActiveJobTrackerRecord'
|
82
90
|
|
83
|
-
after_create :
|
91
|
+
after_create :process_import
|
84
92
|
|
85
|
-
def
|
93
|
+
def process_import
|
86
94
|
# The tracked record must be passed into the job as the first argument
|
87
95
|
ProcessImportJob.perform_later(self)
|
88
96
|
end
|
@@ -167,6 +175,7 @@ This will render a default tracker UI with progress bar, status badge, and job i
|
|
167
175
|
#### Custom Rendering
|
168
176
|
|
169
177
|
You can customize the tracker UI by creating your own partials and using the ActiveJobTrackerRecord model attributes:
|
178
|
+
|
170
179
|
- Make sure to set the `config.default_partial` to the new partial path
|
171
180
|
- Each job block needs to be wrapped with `id="active_job_tracker_<%= tracker.id %>"` for turbo to update your frontend
|
172
181
|
|
@@ -87,7 +87,7 @@ class ActiveJobTrackerRecord < ApplicationRecord
|
|
87
87
|
private
|
88
88
|
|
89
89
|
def broadcast_changes
|
90
|
-
broadcast_replace_to(
|
90
|
+
ActiveJobTracker.configuration.turbo_stream_channel.constantize.broadcast_replace_to(
|
91
91
|
"active_job_trackers",
|
92
92
|
target: "active_job_tracker_#{self.id}",
|
93
93
|
partial: ActiveJobTracker.configuration.default_partial,
|
@@ -6,7 +6,7 @@
|
|
6
6
|
html_options ||= {}
|
7
7
|
css_class = html_options[:class] || "active_job_tracker-container"
|
8
8
|
%>
|
9
|
-
<%= turbo_stream_from "active_job_trackers" %>
|
9
|
+
<%= turbo_stream_from "active_job_trackers", channel: ActiveJobTracker.configuration.turbo_stream_channel %>
|
10
10
|
<div class="<%= css_class %>" data-controller="active_job_tracker-container">
|
11
11
|
<%= content %>
|
12
12
|
</div>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%
|
2
|
+
percentage = active_job_tracker_record.progress_percentage
|
3
|
+
status = active_job_tracker_record.status
|
4
|
+
|
5
|
+
# Calculate the stroke-dasharray and stroke-dashoffset for the circle
|
6
|
+
circumference = 2 * Math::PI * 45 # 45 is the radius of the circle
|
7
|
+
stroke_dashoffset = circumference * (1 - percentage / 100.0)
|
8
|
+
%>
|
9
|
+
|
10
|
+
<div class="active_job_tracker-radial-progress">
|
11
|
+
<svg width="100" height="100" viewBox="0 0 100 100">
|
12
|
+
<circle
|
13
|
+
class="active_job_tracker-radial-progress-bg"
|
14
|
+
cx="50"
|
15
|
+
cy="50"
|
16
|
+
r="45"
|
17
|
+
fill="none"
|
18
|
+
stroke-width="8"
|
19
|
+
/>
|
20
|
+
<circle
|
21
|
+
class="active_job_tracker-radial-progress-fill active_job_tracker-radial-progress-<%= status %>"
|
22
|
+
cx="50"
|
23
|
+
cy="50"
|
24
|
+
r="45"
|
25
|
+
fill="none"
|
26
|
+
stroke-width="8"
|
27
|
+
stroke-dasharray="<%= circumference %>"
|
28
|
+
stroke-dashoffset="<%= stroke_dashoffset %>"
|
29
|
+
transform="rotate(-90 50 50)"
|
30
|
+
/>
|
31
|
+
<text
|
32
|
+
class="active_job_tracker-radial-progress-text"
|
33
|
+
x="50"
|
34
|
+
y="50"
|
35
|
+
text-anchor="middle"
|
36
|
+
dominant-baseline="middle"
|
37
|
+
>
|
38
|
+
<%= percentage %>%
|
39
|
+
</text>
|
40
|
+
</svg>
|
41
|
+
</div>
|
@@ -23,6 +23,10 @@ module ActiveJobTracker
|
|
23
23
|
# @return [Boolean]
|
24
24
|
attr_accessor :include_style
|
25
25
|
|
26
|
+
# The turbo stream channel to use for broadcasting job tracker updates
|
27
|
+
# @return [String]
|
28
|
+
attr_accessor :turbo_stream_channel
|
29
|
+
|
26
30
|
# Initialize with default values
|
27
31
|
def initialize
|
28
32
|
@default_target = 100
|
@@ -30,6 +34,7 @@ module ActiveJobTracker
|
|
30
34
|
@auto_broadcast = true
|
31
35
|
@default_partial = "active_job_tracker/active_job_tracker"
|
32
36
|
@include_style = true
|
37
|
+
@turbo_stream_channel = "Turbo::StreamsChannel"
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -22,4 +22,8 @@ ActiveJobTracker.configure do |config|
|
|
22
22
|
# Whether to include the style in the job tracker (default: true)
|
23
23
|
# When true, the gem's CSS styles are automatically included
|
24
24
|
config.include_style = true
|
25
|
+
|
26
|
+
# The turbo stream channel to use for broadcasting job tracker updates
|
27
|
+
# (default: 'Turbo::StreamsChannel')
|
28
|
+
config.turbo_stream_channel = "Turbo::StreamsChannel"
|
25
29
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_job_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seena Sabti
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-09 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- app/models/active_job_tracker_record.rb
|
121
121
|
- app/views/active_job_tracker/_active_job_tracker.html.erb
|
122
122
|
- app/views/active_job_tracker/_active_job_tracker_wrapper.html.erb
|
123
|
+
- app/views/active_job_tracker/_radial_progress.html.erb
|
123
124
|
- lib/active_job_tracker.rb
|
124
125
|
- lib/active_job_tracker/configuration.rb
|
125
126
|
- lib/active_job_tracker/engine.rb
|