Skip to content
Snippets Groups Projects
Commit 57d28028 authored by Martin Mareš's avatar Martin Mareš
Browse files

DB: Tabulka s výsledky zpracování scanů

parent abc0f91b
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !81. Comments created here will be created in the context of that merge request.
......@@ -397,3 +397,20 @@ CREATE VIEW region_task_stats AS
JOIN solutions s USING(user_id, task_id)
JOIN region_descendants rd ON rd.descendant = c.place_id
GROUP BY r.round_id, rd.region, t.task_id;
-- Stav zpracování scanů (vázaný na joby)
CREATE TABLE scan_pages (
job_id int NOT NULL REFERENCES jobs(job_id) ON DELETE CASCADE,
file_nr int NOT NULL, -- co to je za stránku (od 0)
page_nr int NOT NULL,
user_id int DEFAULT NULL REFERENCES users(user_id), -- přiřazení účastníkovi a úloze
task_id int DEFAULT NULL REFERENCES tasks(task_id),
seq_id int NOT NULL, -- pořadové číslo v rámci úlohy (od 0)
-- Pokud user_id i task_id jsou NULL, seq_id znamená:
-- -1 pro stránku vyžadující pozornost
-- -2 pro prázdnou stránku
-- -3 pro pokračovací stránku
-- -4 pro stránku, která nepatří do této soutěže
UNIQUE (job_id, file_nr, page_nr)
);
......@@ -4,3 +4,13 @@ ALTER TYPE job_type ADD VALUE 'create_protocols';
ALTER TYPE job_type ADD VALUE 'process_scans';
ALTER TYPE job_state ADD VALUE 'preparing';
CREATE TABLE scan_pages (
job_id int NOT NULL REFERENCES jobs(job_id) ON DELETE CASCADE,
file_nr int NOT NULL, -- co to je za stránku
page_nr int NOT NULL,
user_id int DEFAULT NULL REFERENCES users(user_id), -- přiřazení účastníkovi a úloze
task_id int DEFAULT NULL REFERENCES tasks(task_id),
seq_id int NOT NULL, -- pořadové číslo v rámci úlohy
UNIQUE (job_id, file_nr, page_nr)
);
......@@ -764,6 +764,29 @@ class RegionTaskStat(Base):
task = relationship('Task')
class ScanPage(Base):
__tablename__ = 'scan_pages'
job_id = Column(Integer, ForeignKey('jobs.job_id', ondelete='CASCADE'), primary_key=True, nullable=False)
file_nr = Column(Integer, primary_key=True, nullable=False)
page_nr = Column(Integer, primary_key=True, nullable=False)
user_id = Column(Integer, ForeignKey('users.user_id'))
task_id = Column(Integer, ForeignKey('tasks.task_id'))
seq_id = Column(Integer, nullable=False)
UniqueConstraint('job_id', 'file_nr', 'page_nr')
job = relationship('Job')
user = relationship('User')
task = relationship('Task')
# Speciální seq_id ve ScanPage
SCAN_PAGE_FIX = -1
SCAN_PAGE_EMPTY = -2
SCAN_PAGE_CONTINUE = -3
SCAN_PAGE_UFO = -4
_engine: Optional[Engine] = None
_session: Optional[Session] = None
flask_db: Any = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment