Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Rybička
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Rybička
Commits
d718632d
You need to sign in or sign up before continuing.
Commit
d718632d
authored
1 year ago
by
Tomáš Valenta
Browse files
Options
Downloads
Patches
Plain Diff
fix is_playing on server
parent
7c08d2e0
No related branches found
No related tags found
1 merge request
!9
Release
Pipeline
#15169
passed
1 year ago
Stage: build
Stage: test_deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
static_src/timer.js
+3
-10
3 additions, 10 deletions
static_src/timer.js
timer/consumers.py
+17
-17
17 additions, 17 deletions
timer/consumers.py
with
20 additions
and
27 deletions
static_src/timer.js
+
3
−
10
View file @
d718632d
...
...
@@ -152,19 +152,12 @@ $(window).ready(
if
(
"
is_running
"
in
data
)
{
if
(
data
[
"
is_running
"
])
{
// Reset if we are playing again.
// Don't do anything if we have reached an inconsistent state,
// where the timer is at 0 but server still reports it playing.
// This will be resolved within a few milliseconds.
const
remainingTime
=
window
.
timer
.
getTimeValues
()
if
(
remainingTime
.
seconds
===
0
&&
remainingTime
.
minutes
===
0
)
{
window
.
timer
=
new
Timer
({
countdown
:
true
,
startValues
:
{
minutes
:
window
.
startingTime
.
minutes
,
seconds
:
window
.
startingTime
.
seconds
,
}
})
assignEventListeners
()
}
window
.
timer
.
start
()
...
...
This diff is collapsed.
Click to expand it.
timer/consumers.py
+
17
−
17
View file @
d718632d
...
...
@@ -11,6 +11,20 @@ from channels.generic.websocket import AsyncWebsocketConsumer
running_timer_threads
=
[]
def
handle_expired_timer
(
timer
)
->
bool
:
if
timer
.
minutes
==
0
and
timer
.
seconds
==
0
:
# Stop the thread if we have reached the end
timer
.
is_running
=
False
timer
.
save
()
running_timer_threads
.
remove
(
timer
.
id
)
return
True
return
False
def
tick_timer
(
timer
,
iteration
:
int
,
total_seconds
:
int
)
->
None
:
second_compensation
=
0
...
...
@@ -32,26 +46,10 @@ def tick_timer(timer, iteration: int, total_seconds: int) -> None:
running_timer_threads
.
remove
(
timer
.
id
)
return
if
timer
.
minutes
==
0
and
timer
.
seconds
==
0
:
# Stop the thread if we have reached the end
running_timer_threads
.
remove
(
timer
.
id
)
return
handle_expired_timer
(
timer
)
start_time
=
timeit
.
default_timer
()
print
(
timer
.
minutes
,
timer
.
seconds
)
if
timer
.
minutes
==
0
and
timer
.
seconds
==
0
:
# Stop the thread if we have reached the end
timer
.
is_running
=
False
timer
.
save
()
running_timer_threads
.
remove
(
timer
.
id
)
return
if
iteration
!=
timer
.
iteration
:
# Stop the thread if there is a new timer
...
...
@@ -66,6 +64,8 @@ def tick_timer(timer, iteration: int, total_seconds: int) -> None:
timer
.
minutes
=
minutes
timer
.
seconds
=
seconds
handle_expired_timer
(
timer
)
timer
.
save
()
end_time
=
timeit
.
default_timer
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment