Skip to content
Open

#355 #477

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add all_runs, sessions_delivered
  • Loading branch information
jcszymansk committed Oct 15, 2018
commit e8037e769f5c180afa5eede3a474e87296859293
23 changes: 23 additions & 0 deletions naucse/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,10 +943,33 @@ def active_runs():

return len(ongoing)

def all_runs():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Myslím, že je název tento fuknce lehce matoucí, myslím že něco jako count_all_runs by bylo lepší, přeci jen to nevrací kurzy, ale jejich počet...

all_years = list(model.safe_run_years.keys())

return sum([len(model.runs_from_year(year)) for year in all_years])

def sessions_delivered():
today = datetime.date.today()
all_years = list(model.safe_run_years.keys())

all_runs = []
for year in all_years:
all_runs.extend(model.runs_from_year(year))

all_sessions = []
for run in all_runs:
all_sessions.extend(list(run.sessions.values()))

return len([session for session in all_sessions if session.date < today])


def basic_stat(name):
if name == 'active_runs':
return active_runs()
elif name == 'all_runs':
return all_runs()
elif name == 'sessions_delivered':
return sessions_delivered()
else:
return 0

Expand Down