Skip to content

Commit 2a1609c

Browse files
committed
util/file-use: fix file_access_log for filename search -- fixes #8586
1 parent 1695444 commit 2a1609c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/packages/util/db-schema/file-use.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import { Table } from "./types";
77
import { minutes_ago } from "../misc";
88
import { SCHEMA as schema } from "./index";
99

10+
// Helper function to normalize dates for comparison
11+
function getTime(date: any): number {
12+
if (!date) return 0;
13+
if (date instanceof Date) return date.getTime();
14+
if (typeof date === "string") return new Date(date).getTime();
15+
return 0;
16+
}
17+
1018
/* TODO: for postgres rewrite after done we MIGHT completely redo file_use to eliminate
1119
the id field, use project_id, path as a compound primary key, and maybe put users in
1220
another table with a relation. There is also expert discussion about this table in the
@@ -92,12 +100,14 @@ Table({
92100
// Otherwise we touch the project just for seeing notifications or opening
93101
// the file, which is confusing and wastes a lot of resources.
94102
const x = obj.users != null ? obj.users[account_id] : undefined;
95-
// edit/chat/open fields are now strings due to using conat and not auto
96-
// autoconverting them to Dates at this point, hence comparing iso strings:
97-
const recent = minutes_ago(3).toISOString();
103+
// edit/chat/open fields may be strings or Date objects depending on how they're processed
104+
const recentTime = minutes_ago(3).getTime();
105+
98106
if (
99107
x != null &&
100-
(x.edit >= recent || x.chat >= recent || x.open >= recent)
108+
(getTime(x.edit) >= recentTime ||
109+
getTime(x.chat) >= recentTime ||
110+
getTime(x.open) >= recentTime)
101111
) {
102112
db.touch({ project_id: obj.project_id, account_id });
103113
// Also log that this particular file is being used/accessed; this

0 commit comments

Comments
 (0)