-
Notifications
You must be signed in to change notification settings - Fork 19
Expose rule false positive ratio to rule hit table. #1328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
d4e3b4b to
a5a7e53
Compare
|
|
||
| create index concurrently if not exists idx_case_events_by_org | ||
| on case_events (org_id, event_type, created_at) | ||
| where event_type in ('outcome_updated'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created the index manually (
repositories/migrations/20251118115800_add_case_event_org_id.sql
Outdated
Show resolved
Hide resolved
f48fd68 to
2cf9154
Compare
Pascal-Delange
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense like this 👍
As discussed in DM, check the limit placement, I think as it is we can lose some decisions/rules due to waterparking/pagination/limit too late.
repositories/migrations/20251118115800_add_case_event_org_id.sql
Outdated
Show resolved
Hide resolved
Pascal-Delange
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
1d8fff4 to
30d0fe4
Compare
The false positive ratio must be computed from the latest outcome of closed cases where a rule appears, this required adding the org ID to case events, ingesting some of the case events, and performing a separate query.
30d0fe4 to
7a8806e
Compare
The false positive ratio must be computed from the latest outcome of closed cases where a rule appears, this required adding the org ID to case events, ingesting some of the case events, and performing a separate query.
A migration adds the org ID, an appropriate index and backfills the data for the
case_eventstable.Not tested on production data yet.
Note
Adds false-positive ratio to the rule hit table by exporting latest closed-case outcomes per rule to
rule_hit_outcomes, requiringorg_idoncase_eventsand updating event creation paths.analytics.RuleHitTablewithrule_idandfalse_positive_ratio; addFalsePositiveRatiotype.RuleHitTableendpoint now joins aggregated false positives fromrule_hit_outcomes(latest outcome per case).AnalyticsCopyCaseEventsto copy latestoutcome_updatedevents for closed cases intorule_hit_outcomes(partitioned by org/year/month/trigger_object_type).exportCaseEventsin parallel with other exports and watermarks viaAnalyticsGetLatestRow.WithCtesRawto build CTEs with raw placeholders.OrgId uuid.UUIDtomodels.CaseEvent,CreateCaseEventAttributes, and DB adapter; batch insert now writesorg_id.org_idcolumn tocase_events, backfill fromcases, and create partial indexidx_case_events_by_orgon(org_id, event_type, created_at).OrgId(case create/update, assign/unassign, snooze/unsnooze, comments/tags/files, decision review, SAR, screenings, rule snooze, escalate, mass update).UpdateDecisionsWithEventsto acceptorgIdand propagate across callers.Written by Cursor Bugbot for commit 30d0fe4. This will update automatically on new commits. Configure here.