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
dd1263f7
Commit
dd1263f7
authored
3 years ago
by
Jiří Setnička
Browse files
Options
Downloads
Patches
Plain Diff
DB a Score: Přidání score_suborder do tabulky participations a třídění podle něj
Issue
#210
parent
3cc5269b
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
db/db.ddl
+1
-0
1 addition, 0 deletions
db/db.ddl
db/upgrade-20211120.sql
+4
-0
4 additions, 0 deletions
db/upgrade-20211120.sql
mo/db.py
+1
-0
1 addition, 0 deletions
mo/db.py
mo/score.py
+3
-2
3 additions, 2 deletions
mo/score.py
with
9 additions
and
2 deletions
db/db.ddl
+
1
−
0
View file @
dd1263f7
...
...
@@ -177,6 +177,7 @@ CREATE TABLE participations (
contest_id int NOT NULL REFERENCES contests(contest_id),
place_id int NOT NULL REFERENCES places(place_id), -- konkrétní soutěžní místo (default: region contestu)
state part_state NOT NULL,
score_suborder int DEFAULT NULL,
PRIMARY KEY (user_id, contest_id)
);
...
...
This diff is collapsed.
Click to expand it.
db/upgrade-20211120.sql
0 → 100644
+
4
−
0
View file @
dd1263f7
SET
ROLE
'mo_osmo'
;
ALTER
TABLE
participations
ADD
COLUMN
score_suborder
int
DEFAULT
NULL
;
This diff is collapsed.
Click to expand it.
mo/db.py
+
1
−
0
View file @
dd1263f7
...
...
@@ -494,6 +494,7 @@ class Participation(Base):
contest_id
=
Column
(
Integer
,
ForeignKey
(
'
contests.contest_id
'
),
primary_key
=
True
,
nullable
=
False
)
place_id
=
Column
(
Integer
,
ForeignKey
(
'
places.place_id
'
),
nullable
=
False
)
state
=
Column
(
Enum
(
PartState
,
name
=
'
part_state
'
),
nullable
=
False
)
score_suborder
=
Column
(
Integer
,
nullable
=
True
)
contest
=
relationship
(
'
Contest
'
,
primaryjoin
=
'
Participation.contest_id == Contest.contest_id
'
)
place
=
relationship
(
'
Place
'
,
primaryjoin
=
'
Participation.place_id == Place.place_id
'
)
...
...
This diff is collapsed.
Click to expand it.
mo/score.py
+
3
−
2
View file @
dd1263f7
...
...
@@ -273,7 +273,7 @@ class Score:
if
self
.
round
.
score_mode
==
db
.
RoundScoreMode
.
basic
:
# Základní mód - jen podle celkových bodů, se sdílenými místy
for
result
in
self
.
_results
.
values
():
result
.
_order_key
=
[
-
result
.
get_total_points
()]
result
.
_order_key
=
[
-
result
.
get_total_points
()
,
result
.
pion
.
score_suborder
or
0
]
elif
self
.
round
.
score_mode
==
db
.
RoundScoreMode
.
mo
:
self
.
_add_mo_order_key
()
...
...
@@ -382,7 +382,7 @@ class Score:
# Pokud jsme našli stejný klíč, opakujeme cyklus s minulým kolem
step
+=
1
# Na konec třídícího klíče přidáme ročník (menší ročník první)
# Na konec třídícího klíče přidáme ročník (menší ročník první)
a dotřiďovací klíč
for
result
in
self
.
_results
.
values
():
grade
=
normalize_grade
(
result
.
pant
.
grade
)
if
grade
==
-
1
:
...
...
@@ -391,6 +391,7 @@ class Score:
f
"
Účastník
{
result
.
user
.
first_name
}
{
result
.
user
.
last_name
}
má neplatný ročník
{
result
.
pant
.
grade
}
"
)
result
.
_order_key
.
append
(
grade
)
result
.
_order_key
.
append
(
result
.
pion
.
score_suborder
or
0
)
if
self
.
_exists_same_order_key
():
self
.
_add_message
(
...
...
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