Cross Reference: proof_evaluation_state_updater.rb
xref
: /
ontohub
/
lib
/
proof_evaluation_state_updater.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
class
ProofEvaluationStateUpdater
MUTEX_EXPIRATION
=
2.minutes
attr_reader
:
proof_attempt
, :
state
, :
message
, :
theorem
def
initialize
(
proof_attempt
,
state
,
message
=
nil
)
@
proof_attempt
=
proof_attempt
@
state
=
state.to
_sym
@
message
=
message
@
theorem
=
proof_attempt.theorem
end
def
call
proof_attempt.update
_state
!
(
state
,
message
)
update_theorem_state
end
def
update_theorem_state
Semaphore.exclusively
(
theorem.locid
,
expiration
:
MUTEX_EXPIRATION
)
do
theorem_message
=
nil
theorem_state
=
State
.
most_successful
(
theorem.proof_attempts.select
(:
state
)
.
map
(&:
state
)
)
if
theorem_state
==
'failed'
theorem_message
=
I18n.t
(
'
proof_evaluation_state_updater.failed
_proof_attempts'
,
proof_attempts
:
failed_proof_attempts.map
(&:
number
)
.
join
(
', '
)
)
end
theorem.update
_state
!
(
theorem_state
,
theorem_message
)
end
end
def
failed_proof_attempts
theorem.proof_attempts.select
(%i
(
id
number
)
)
.
state
(:
failed
)
end
end