Skip to content

Commit

Permalink
database.files_db:FilesDB.log_paths - join access and statutory files
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Dec 18, 2024
1 parent 33f4b5c commit bd7021c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion acacore/database/files_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ def __init__(
EventPath,
"log_paths",
f"""
select coalesce(fo.relative_path, fm.relative_path) as file_relative_path, l.* from {self.log.name} l
select coalesce(fo.relative_path, fm.relative_path, fa.relative_path, fs.relative_path) as file_relative_path, l.* from {self.log.name} l
left join {self.original_files.name} fo on l.file_type = 'original' and fo.uuid = l.file_uuid
left join {self.master_files.name} fm on l.file_type = 'master' and fm.uuid = l.file_uuid
left join {self.access_files.name} fa on l.file_type = 'access' and fa.uuid = l.file_uuid
left join {self.statutory_files.name} fs on l.file_type = 'statutory' and fs.uuid = l.file_uuid
""",
)

Expand Down
8 changes: 5 additions & 3 deletions acacore/database/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ def upgrade_4to4_1(con: Connection) -> Version:
""")
con.execute("""
create view log_paths as
select coalesce(fo.relative_path, fm.relative_path) as file_relative_path, l.*
select coalesce(fo.relative_path, fm.relative_path, fa.relative_path, fs.relative_path) as file_relative_path, l.*
from log l
left join files_original fo on l.file_type = 'original' and fo.uuid = l.file_uuid
left join files_master fm on l.file_type = 'master' and fm.uuid = l.file_uuid
left join files_original fo on l.file_type = 'original' and fo.uuid = l.file_uuid
left join files_master fm on l.file_type = 'master' and fm.uuid = l.file_uuid
left join files_access fa on l.file_type = 'access' and fa.uuid = l.file_uuid
left join files_statutory fs on l.file_type = 'statutory' and fs.uuid = l.file_uuid
""")
con.commit()

Expand Down

0 comments on commit bd7021c

Please sign in to comment.