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
c75139ba
Commit
c75139ba
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
DB: Tabulka pro asynchronní úlohy
parent
ff468bb5
No related branches found
No related tags found
2 merge requests
!14
Asynchronní joby
,
!9
WIP: Zárodek uživatelské části webu a submitování
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
db/db.ddl
+29
-1
29 additions, 1 deletion
db/db.ddl
mo/db.py
+31
-0
31 additions, 0 deletions
mo/db.py
with
60 additions
and
1 deletion
db/db.ddl
+
29
−
1
View file @
c75139ba
...
@@ -225,4 +225,32 @@ CREATE TABLE log (
...
@@ -225,4 +225,32 @@ CREATE TABLE log (
details jsonb NOT NULL -- detaily (závislé na typu)
details jsonb NOT NULL -- detaily (závislé na typu)
);
);
-- FIXME: Indexy
-- Asynchronní úlohy
CREATE TYPE job_type AS ENUM (
'download_submits',
'upload_feedback'
);
CREATE TYPE job_state AS ENUM (
'ready',
'running',
'done', -- Hotovo, out_json a out_file jsou platné
'failed' -- Interní chyba při zpracování, viz log
);
CREATE TABLE jobs (
job_id serial PRIMARY KEY,
type job_type NOT NULL,
state job_state NOT NULL,
user_id int NOT NULL REFERENCES users(user_id), -- komu patří
created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- kdy byl založen
finished_at timestamp with time zone DEFAULT NULL, -- kdy doběhl
expires_at timestamp with time zone DEFAULT NULL, -- kdy bude automaticky smazán
description text NOT NULL DEFAULT '',
in_json jsonb DEFAULT NULL,
out_json jsonb DEFAULT NULL,
-- Soubory jsou součástí úlohy a po jejím ukončení budou smazány
in_file varchar(255) DEFAULT NULL,
out_file varchar(255) DEFAULT NULL
);
This diff is collapsed.
Click to expand it.
mo/db.py
+
31
−
0
View file @
c75139ba
...
@@ -459,6 +459,37 @@ class Solution(Base):
...
@@ -459,6 +459,37 @@ class Solution(Base):
user
=
relationship
(
'
User
'
)
user
=
relationship
(
'
User
'
)
class
JobType
(
MOEnum
):
download_submits
=
auto
()
upload_feedback
=
auto
()
class
JobState
(
MOEnum
):
ready
=
auto
()
running
=
auto
()
done
=
auto
()
failed
=
auto
()
class
Job
(
Base
):
__tablename__
=
'
jobs
'
job_id
=
Column
(
Integer
,
primary_key
=
True
,
server_default
=
text
(
"
nextval(
'
jobs_job_id_seq
'
::regclass)
"
))
type
=
Column
(
Enum
(
JobType
,
name
=
'
job_type
'
),
nullable
=
False
)
state
=
Column
(
Enum
(
JobState
,
name
=
'
job_state
'
),
nullable
=
False
)
user_id
=
Column
(
Integer
,
ForeignKey
(
'
users.user_id
'
),
nullable
=
False
)
description
=
Column
(
Text
,
nullable
=
False
,
server_default
=
text
(
"''
::text
"
))
created_at
=
Column
(
DateTime
(
True
),
nullable
=
False
,
server_default
=
text
(
"
CURRENT_TIMESTAMP
"
))
finished_at
=
Column
(
DateTime
(
True
))
expires_at
=
Column
(
DateTime
(
True
))
in_json
=
Column
(
JSONB
)
in_file
=
Column
(
String
(
255
),
server_default
=
text
(
"
NULL::character varying
"
))
out_json
=
Column
(
JSONB
)
out_file
=
Column
(
String
(
255
),
server_default
=
text
(
"
NULL::character varying
"
))
user
=
relationship
(
'
User
'
)
_engine
:
Optional
[
Engine
]
=
None
_engine
:
Optional
[
Engine
]
=
None
_session
:
Optional
[
Session
]
=
None
_session
:
Optional
[
Session
]
=
None
flask_db
:
Any
=
None
flask_db
:
Any
=
None
...
...
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