Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
13db23d7
Commit
13db23d7
authored
1 year ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
WIP: Statistiky
parent
5aae4219
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/web/org_export.py
+44
-1
44 additions, 1 deletion
mo/web/org_export.py
with
44 additions
and
1 deletion
mo/web/org_export.py
+
44
−
1
View file @
13db23d7
...
...
@@ -2,7 +2,7 @@
from
flask
import
request
,
g
import
locale
from
sqlalchemy
import
and_
from
sqlalchemy
import
and_
,
func
from
sqlalchemy.orm
import
aliased
,
joinedload
import
werkzeug.exceptions
...
...
@@ -134,3 +134,46 @@ def org_export_school_orgs(region: str):
filename
=
'
skoly-organizatori
'
,
)
return
table
.
send_as
(
format
,
streaming
=
True
)
@app.route
(
'
/org/export/z-stats/<int:year>/<int:seq>
'
)
def
org_export_z_stats
(
year
:
int
,
seq
:
int
):
format
=
request
.
args
.
get
(
'
format
'
,
'
en_csv
'
)
sess
=
db
.
get_session
()
regions
=
(
sess
.
query
(
db
.
Place
)
.
filter_by
(
level
=
1
)
.
all
())
rounds
=
(
sess
.
query
(
db
.
Round
)
.
filter
(
db
.
Round
.
category
.
like
(
'
Z%
'
))
.
filter_by
(
year
=
year
,
seq
=
seq
)
.
all
())
print
(
rounds
)
table
=
{}
for
rnd
in
rounds
:
# FIXME: Check rights
reg
=
aliased
(
db
.
Place
)
print
(
'
=========
'
,
rnd
.
round_code
())
pions
=
(
sess
.
query
(
reg
.
place_id
,
reg
.
code
,
func
.
count
(
db
.
Participation
.
user_id
))
.
select_from
(
db
.
Participation
)
.
join
(
db
.
Contest
,
db
.
Contest
.
contest_id
==
db
.
Participation
.
contest_id
)
.
filter
(
db
.
Contest
.
round
==
rnd
)
.
join
(
db
.
RegionDescendant
,
db
.
RegionDescendant
.
descendant
==
db
.
Contest
.
place_id
)
.
join
(
reg
,
reg
.
place_id
==
db
.
RegionDescendant
.
region
)
.
filter
(
reg
.
level
==
1
)
.
filter
(
sess
.
query
(
db
.
Solution
)
.
with_entities
(
func
.
sum
(
db
.
Solution
.
points
))
.
select_from
(
db
.
Solution
)
.
filter
(
db
.
Solution
.
user_id
==
db
.
Participation
.
user_id
)
.
join
(
db
.
Task
,
db
.
Task
.
round
==
rnd
)
.
filter
(
db
.
Solution
.
task_id
==
db
.
Task
.
task_id
)
.
scalar_subquery
()
>
0
)
.
group_by
(
reg
.
place_id
)
.
all
())
print
(
pions
)
return
""
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