Skip to content

Commit

Permalink
database:files_db - add checksum count view to count occurrences of f…
Browse files Browse the repository at this point in the history
…iles
  • Loading branch information
MatteoCampinoti94 committed Nov 3, 2023
1 parent ea896e4 commit 6cde279
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions acacore/database/files_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from acacore.models.file import ConvertedFile
from acacore.models.file import File
from acacore.models.history import HistoryEntry
from acacore.models.identification import ChecksumCount
from acacore.models.identification import SignatureCount
from acacore.models.metadata import Metadata
from acacore.utils.functions import or_none
Expand Down Expand Up @@ -78,6 +79,34 @@ def __init__(
self.files.model,
f'"{self.files.name}".warning IS NOT null',
)
self.checksum_count = self.create_view(
"_ChecksumCount",
self.files,
ChecksumCount,
None,
[
Column("checksum", "varchar", str, str, False, False, False),
],
[
(Column("count", "int", str, str), "ASC"),
],
select_columns=[
Column(
"checksum",
"varchar",
or_none(str),
or_none(str),
False,
False,
False,
),
SelectColumn(
f'count("{self.files.name}.checksum")',
int,
"count",
),
],
)
self.signature_count = self.create_view(
"_SignatureCount",
self.files,
Expand Down

0 comments on commit 6cde279

Please sign in to comment.