Skip to content

Commit

Permalink
Add audio message count to attachment totals analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Mar 6, 2024
1 parent 75445ca commit 73341c1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions ica/analyzers/attachment_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def main() -> None:
.count()
.item()
),
"audio_messages": (dfs.attachments["filename"].str.endswith(".caf").sum()),
"recorded_videos": (dfs.attachments["mime_type"].eq("video/quicktime").sum()),
}
ica.output_results(
Expand Down
2 changes: 1 addition & 1 deletion ica/analyzers/totals_by_day.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def main() -> None:
)
ica.output_results(
(
dfs.messages
dfs.messages[["text", "is_from_me", "datetime", "is_reaction"]]
# Count all "text" column values by converting them to integers
# (always 1), because resampling the DataFrame will remove all
# non-numeric columns
Expand Down
4 changes: 3 additions & 1 deletion ica/queries/attachments.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
SELECT "mime_type"
SELECT "mime_type",
"filename",
"message_id"
FROM "attachment"
INNER JOIN "message_attachment_join"
ON "attachment"."ROWID" = "attachment_id"
Expand Down
1 change: 1 addition & 0 deletions ica/queries/messages.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SELECT
"ROWID",
"text",
"attributedBody",
datetime("message"."date" / 1000000000 + strftime("%s", "2001-01-01") ,"unixepoch") as "datetime",
Expand Down
1 change: 1 addition & 0 deletions tests/data/dbs/chats/attachment.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"ROWID": "caa5c5fd-f301-4104-b0c4-934f2e52992b",
"filename": "abc.gif",
"mime_type": "image/gif"
}
]

0 comments on commit 73341c1

Please sign in to comment.