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
877303ff
Commit
877303ff
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
DB: Lepší reprezentace škol, které jsou současně ZŠ a SŠ
parent
c96a5047
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
TODO
+3
-0
3 additions, 0 deletions
TODO
bin/init-schools
+21
-14
21 additions, 14 deletions
bin/init-schools
db/db.ddl
+2
-8
2 additions, 8 deletions
db/db.ddl
mo/db.py
+3
-8
3 additions, 8 deletions
mo/db.py
with
29 additions
and
30 deletions
TODO
+
3
−
0
View file @
877303ff
...
@@ -13,3 +13,6 @@ WARNING: Obec Úvaly je podle rejstříku v okrese CZ0203, ale pod RUIAN v CZ020
...
@@ -13,3 +13,6 @@ WARNING: Obec Úvaly je podle rejstříku v okrese CZ0203, ale pod RUIAN v CZ020
WARNING: Obec Dobřichovice je podle rejstříku v okrese CZ0202, ale pod RUIAN v CZ020A => preferuji RUIAN
WARNING: Obec Dobřichovice je podle rejstříku v okrese CZ0202, ale pod RUIAN v CZ020A => preferuji RUIAN
WARNING: Obec Pchery je podle rejstříku v okrese CZ0204, ale pod RUIAN v CZ0203 => preferuji RUIAN
WARNING: Obec Pchery je podle rejstříku v okrese CZ0204, ale pod RUIAN v CZ0203 => preferuji RUIAN
WARNING: Obec Poděbrady je podle rejstříku v okrese CZ0204, ale pod RUIAN v CZ0208 => preferuji RUIAN
WARNING: Obec Poděbrady je podle rejstříku v okrese CZ0204, ale pod RUIAN v CZ0208 => preferuji RUIAN
- konstrukce rozumných názvů škol
- přejmenovat školy, které mají duplicitní RED_IZO
This diff is collapsed.
Click to expand it.
bin/init-schools
+
21
−
14
View file @
877303ff
...
@@ -34,7 +34,6 @@ def import_schools(path: Path, nuts: str):
...
@@ -34,7 +34,6 @@ def import_schools(path: Path, nuts: str):
for
line
in
file
:
for
line
in
file
:
f
=
line
.
split
(
'
\t
'
)
f
=
line
.
split
(
'
\t
'
)
red_izo
=
f
[
columns
[
'
Red IZO
'
]]
red_izo
=
f
[
columns
[
'
Red IZO
'
]]
izo
=
f
[
columns
[
'
IZO
'
]]
druh
=
f
[
columns
[
'
Druh školy/zařízení
'
]]
druh
=
f
[
columns
[
'
Druh školy/zařízení
'
]]
# Address of legal entity
# Address of legal entity
...
@@ -58,22 +57,30 @@ def import_schools(path: Path, nuts: str):
...
@@ -58,22 +57,30 @@ def import_schools(path: Path, nuts: str):
town
=
lookup_town
(
misto2
,
nuts
)
town
=
lookup_town
(
misto2
,
nuts
)
if
druh
.
startswith
(
'
Základní škola
'
):
if
druh
.
startswith
(
'
Základní škola
'
):
stype
=
db
.
SchoolType
.
zs
is_zs
=
True
elif
druh
.
startswith
(
'
Střední škola
'
):
elif
druh
.
startswith
(
'
Střední škola
'
):
stype
=
db
.
SchoolType
.
ss
is_zs
=
False
else
:
else
:
assert
False
,
f
"
Neznámý druh školy:
{
druh
}
"
assert
False
,
f
"
Neznámý druh školy:
{
druh
}
"
school
=
session
.
query
(
db
.
School
).
filter_by
(
level
=
4
,
parent
=
town
.
place_id
,
red_izo
=
red_izo
,
address
=
addr2
).
first
()
if
school
:
assert
school
.
official_name
==
nazev
if
is_zs
:
school
.
is_zs
=
True
else
:
school
.
is_ss
=
True
else
:
school
=
db
.
School
(
school
=
db
.
School
(
level
=
4
,
level
=
4
,
parent
=
town
.
place_id
,
parent
=
town
.
place_id
,
name
=
nazev
,
name
=
nazev
,
type
=
db
.
PlaceType
.
school
,
type
=
db
.
PlaceType
.
school
,
red_izo
=
red_izo
,
red_izo
=
red_izo
,
izo
=
izo
,
official_name
=
nazev
,
official_name
=
nazev
,
address
=
addr2
,
address
=
addr2
,
stype
=
stype
)
is_zs
=
is_zs
,
is_ss
=
not
is_zs
)
session
.
add
(
school
)
session
.
add
(
school
)
global
new_school_cnt
global
new_school_cnt
...
...
This diff is collapsed.
Click to expand it.
db/db.ddl
+
2
−
8
View file @
877303ff
...
@@ -45,19 +45,13 @@ CREATE TABLE places (
...
@@ -45,19 +45,13 @@ CREATE TABLE places (
-- FIXME: Views definovaná rekurzivními selecty nad hierarchií
-- FIXME: Views definovaná rekurzivními selecty nad hierarchií
-- Škola je speciální typ místa s doplňujícími informacemi
-- Škola je speciální typ místa s doplňujícími informacemi
CREATE TYPE school_type AS ENUM (
'zs',
'ss'
);
CREATE TABLE schools (
CREATE TABLE schools (
place_id int PRIMARY KEY REFERENCES places(place_id) ON DELETE CASCADE,
place_id int PRIMARY KEY REFERENCES places(place_id) ON DELETE CASCADE,
red_izo varchar(255) DEFAULT NULL,
red_izo varchar(255) DEFAULT NULL,
izo varchar(255) DEFAULT NULL,
official_name varchar(255) DEFAULT NULL,
official_name varchar(255) DEFAULT NULL,
address varchar(255) DEFAULT NULL,
address varchar(255) DEFAULT NULL,
stype school_type NOT NULL
is_zs boolean NOT NULL DEFAULT false,
is_ss boolean NOT NULL DEFAULT false
);
);
-- Soutěžní kola
-- Soutěžní kola
...
...
This diff is collapsed.
Click to expand it.
mo/db.py
+
3
−
8
View file @
877303ff
...
@@ -49,20 +49,15 @@ class Place(Base):
...
@@ -49,20 +49,15 @@ class Place(Base):
children
=
relationship
(
'
Place
'
,
remote_side
=
[
place_id
])
children
=
relationship
(
'
Place
'
,
remote_side
=
[
place_id
])
class
SchoolType
(
PythonEnum
):
zs
=
auto
()
ss
=
auto
()
class
School
(
Place
):
class
School
(
Place
):
__tablename__
=
'
schools
'
__tablename__
=
'
schools
'
place_id
=
Column
(
Integer
,
ForeignKey
(
'
places.place_id
'
),
primary_key
=
True
)
place_id
=
Column
(
ForeignKey
(
'
places.place_id
'
,
ondelete
=
'
CASCADE
'
),
primary_key
=
True
)
red_izo
=
Column
(
String
(
255
),
server_default
=
text
(
"
NULL::character varying
"
))
red_izo
=
Column
(
String
(
255
),
server_default
=
text
(
"
NULL::character varying
"
))
izo
=
Column
(
String
(
255
),
server_default
=
text
(
"
NULL::character varying
"
))
official_name
=
Column
(
String
(
255
),
server_default
=
text
(
"
NULL::character varying
"
))
official_name
=
Column
(
String
(
255
),
server_default
=
text
(
"
NULL::character varying
"
))
address
=
Column
(
String
(
255
),
server_default
=
text
(
"
NULL::character varying
"
))
address
=
Column
(
String
(
255
),
server_default
=
text
(
"
NULL::character varying
"
))
stype
=
Column
(
Enum
(
SchoolType
,
name
=
'
school_type
'
),
nullable
=
False
)
is_zs
=
Column
(
Boolean
,
nullable
=
False
,
server_default
=
text
(
"
false
"
))
is_ss
=
Column
(
Boolean
,
nullable
=
False
,
server_default
=
text
(
"
false
"
))
class
Round
(
Base
):
class
Round
(
Base
):
...
...
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