feat(backend): record tag usage in filters to activity.tag_uses
Listing files with a tag filter now logs each referenced tag to activity.tag_uses, flagging it included (positive) or excluded (negated under an odd number of NOTs); the untagged pseudo-token is skipped. The filter AST is reused to determine polarity, so grouped negations like !(A|B) mark both tags excluded. Recording happens only when a filter is first applied — not on cursor pagination or an anchored return — so one browse counts once. The write is best-effort and never fails the listing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,10 @@ type FileRepo interface {
|
||||
|
||||
// RecordView appends a view-history row (activity.file_views) for the user.
|
||||
RecordView(ctx context.Context, fileID uuid.UUID, userID int16) error
|
||||
// RecordTagUses logs the tags referenced in a filter DSL to
|
||||
// activity.tag_uses, flagging each included or excluded. Best-effort
|
||||
// analytics — callers may ignore the error.
|
||||
RecordTagUses(ctx context.Context, userID int16, filterDSL string) error
|
||||
}
|
||||
|
||||
// TagRepo is the persistence interface for tags.
|
||||
|
||||
Reference in New Issue
Block a user