Cross Reference: states.rb
xref
: /
ontohub
/
app
/
models
/
ontology
/
states.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
states.rb revision 17025a117f657b98646b4d56d56137754f523d2e
1516
N/A
module
Ontology
::
States
565
N/A
extend
ActiveSupport
::
Concern
565
N/A
565
N/A
STATES
= %w
(
pending
downloading
processing
done
failed
)
565
N/A
565
N/A
included
do
565
N/A
validates_inclusion_of
:
state
, :
in
=>
STATES
565
N/A
565
N/A
scope
:
state
, ->
(*
states
)
{
565
N/A
where
state
:
states.map
(&:
to_s
)
565
N/A
}
565
N/A
565
N/A
STATES.each
do
|
state
|
565
N/A
eval
"def #{state}?; state == '#{state}'; end"
565
N/A
end
565
N/A
end
565
N/A
565
N/A
module
ClassMethods
565
N/A
# Enqueues new parse jobs for all failed ontologies
565
N/A
def
retry_failed
565
N/A
state
(:
failed
)
.without_parent.find
_each
do
|
ontology
|
926
N/A
ontology.versions.last.try
:
async_parse
926
N/A
end
2614
N/A
end
926
N/A
565
N/A
def
count_by_state
2026
N/A
select
(
"state, count(*) AS count"
)
.
group
(:
state
)
1050
N/A
end
2524
N/A
end
926
N/A
926
N/A
def
changeable
?
2339
N/A
done
?
or
failed
?
2339
N/A
end
2339
N/A
end
926
N/A