Skip to content

Commit

Permalink
Get running status based on operation DB
Browse files Browse the repository at this point in the history
See also: #7
  • Loading branch information
BECATRUE committed Nov 21, 2024
1 parent ba495ec commit 688c260
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions wlm_server/operation/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from operation.models import Operation

def get_running_status(ch: int) -> tuple[bool, bool]:
"""Gets running status of WLM and the given channel based on operation DB.
Args:
ch: Target channel.
Returns:
Tuple with WLM running status and target channel running status.
"""
latest_operations = (
Operation.objects.order_by('channel', 'user', '-occured_at').distinct('channel', 'user')
) # latest operations for each channel and user
on_operations = latest_operations.filter(on=True)
is_wlm_running = on_operations.exists()
is_channel_running = on_operations.filter(channel__channel=ch).exists()
return is_wlm_running, is_channel_running

0 comments on commit 688c260

Please sign in to comment.