This repository has been archived by the owner. It is now read-only.
forked from hirefire/hirefire
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added 2.3.X ActiveRecord compatible backend (without Arel-style scope)
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# encoding: utf-8 | ||
|
||
module HireFire | ||
module Backend | ||
module DelayedJob | ||
module OldActiveRecord | ||
|
||
## | ||
# Counts the amount of queued jobs in the database, | ||
# failed jobs are excluded from the sum | ||
# | ||
# @return [Fixnum] the amount of pending jobs | ||
def jobs | ||
::Delayed::Job.all( | ||
:conditions => ['failed_at IS NULL and run_at <= ?', Time.now.utc] | ||
).count | ||
end | ||
|
||
## | ||
# Counts the amount of jobs that are locked by a worker | ||
# | ||
# @return [Fixnum] the amount of (assumably working) workers | ||
def workers | ||
::Delayed::Job.all( | ||
:conditions => 'locked_by IS NOT NULL' | ||
).count | ||
end | ||
|
||
end | ||
end | ||
end | ||
end | ||
|