
Security News
MCP Steering Committee Launches Official MCP Registry in Preview
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
This gem add a couple of colums to delayed job table, and gives u a basic class for working with progress
Ruby 2.0.0 (as the methods are using keyword arguments.)
You need to have https://github.com/collectiveidea/delayed_job in you gem file
Add this line to your application's Gemfile:
gem 'dj_progress_job'
And then execute:
$ bundle
Run generator (run delayed job generators first!)
$ rails generate dj_progress_job:install
Create a new class that extends ProgressJob::Base
class NewJob < DjProgressJob::Base
def perform
# some actions
end
end
Inside perform method you can use:
update_progress(step: 10) # default step is 1
update_stage('name of stage')
update_stage_progress('name of stage', step: 11)
update_progress_max(progress_max)
methods to update the job progress.
To create a new job use Delayed job enqueue method, and pass the progress_max value
job = Delayed::Job.enqueue NewJob.new(progress_max: 100) # default progress_max is 100
There is also a controller which returns the delayed job with calculated percentage
GET 'dj_progress-jobs/:job_id/'
class NewJob < DjProgressJob::Base
def perform
handler = Handler.new
update_stage('Handling ports')
handler.handle_ports
update_stage_progress('Handling cruise', step: 10)
handler.handle_cruise
update_stage_progress('Handling days', step: 10)
handler.handle_days
update_stage_progress('Handling pick up times', step: 10)
handler.handle_pick_up_times
update_stage_progress('Handling users', step: 10)
handler.handle_users
update_stage_progress('Handling item categories', step: 10)
handler.handle_item_categories
update_stage_progress('Handling items', step: 10)
handler.handle_items
handler.handle_other_items
update_stage_progress('Handling event types', step: 10)
handler.handle_event_types
update_stage_progress('Handling events', step: 10)
handler.handle_events
end
end
= simple_form_for :import, url: [:import], remote: true do |f|
.row
.col-xs-10
= f.input :file, as: :file
.col-xs-2
= f.button :submit, "Import", class: "btn btn-success"
%br
.well{style: "display:none"}
.row
.col-xs-12
.progress-status.text-primary
.row
.col-xs-12
.progress.progress-striped.active
.progress-bar
.text-primary
0%
Example of ajax call (this is a .html.haml remote: true response):
var interval;
$('.hermes-import .well').show();
interval = setInterval(function(){
$.ajax({
url: '/progress-job/' + #{@job.id},
success: function(job){
var stage, progress;
// If there are errors
if (job.last_error != null) {
$('.progress-status').addClass('text-danger').text(job.progress_stage);
$('.progress-bar').addClass('progress-bar-danger');
$('.progress').removeClass('active');
clearInterval(interval);
}
// Upload stage
if (job.progress_stage != null){
stage = job.progress_stage;
progress = job.progress_current / job.progress_max * 100;
} else {
progress = 0;
stage = 'Uploading file';
}
// In job stage
if (progress !== 0){
$('.progress-bar').css('width', progress + '%').text(progress + '%');
}
$('.progress-status').text(stage);
},
error: function(){
// Job is no loger in database which means it finished successfuly
$('.progress').removeClass('active');
$('.progress-bar').css('width', '100%').text('100%');
$('.progress-status').text('Successfully imported!');
clearInterval(interval);
}
})
},100);
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that dj_progress_job demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.