Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6992087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:35:22+00:00 2026-05-27T19:35:22+00:00

I’m using resque-status for Resque/Redis… https://github.com/quirkey/resque-status I basically want to create a new Sinatra

  • 0

I’m using resque-status for Resque/Redis…

https://github.com/quirkey/resque-status

I basically want to create a new Sinatra method .. something like below. I only have 2 JobsWithStatus so it could either return both or a specific one, i dont really care.

post '/getstatus' do
  # return status here of all kinds (or specific)
end

Then I want to output the % complete via jquery on the frontend using a polling timer that checks the status every 5 seconds.

This is what I have

post '/refresh' do
  job_id = PostSaver.create(:length => Forum.count)
  status = Resque::Status.get(job_id)
  redirect '/'
end

It says in the documentation i can just use status.pct_complete but it always returns 0? Even then, I’m new to ruby and even IF the variable showed the proper % complete, I’m not sure how to make that variable work inside of a separate sinatra entry (in /getstatus rather than /refresh).

I tried this however and it keeps returning 0

post '/refresh' do
  job_id = PostSaver.create(:length => Forum.count)
  status = Resque::Status.get(job_id)
  sleep 20
  status.pct_complete.to_s
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:35:22+00:00Added an answer on May 27, 2026 at 7:35 pm

    Saw your question over on reddit…

    To have the status come back as something other than 0, you need to use the at (http://rubydoc.info/github/quirkey/resque-status/master/Resque/JobWithStatus:at) method to set a percentage during the calculation you’re running.

    You probably don’t want sleep calls inside an action. The timer should be in jQuery.


    Sharing Status

    post '/refresh' do
      job_id = PostSaver.create(:length => Forum.count)
      status = Resque::Status.get(job_id)
      sleep 20
      "{'percent_complete':#{status.pct_complete},'job_id':'#{job_id}'}"
    end
    

    Then in whatever is getting the status (some jQuery#ajax call?), you can grab the job_id from the returned JSON and then with your next request, you might do something like:

    post '/status' do
      status = Resque::Status.get(params['job_id'])
      "{'percent_complete':#{status.pct_complete}}"
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
I want use html5's new tag to play a wav file (currently only supported
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.