Add audited opportunity origin review and QA separation

This commit is contained in:
2026-10-09 02:46:36 +02:00
parent 6c7a9c9442
commit 344545430b
18 changed files with 1266 additions and 1 deletions
+2 -1
View File
@@ -58,6 +58,7 @@ class Opportunity extends Model
*/
public function scopePublished(Builder $query): Builder
{
return $query->where('status', 'published')->whereNotNull('published_at')->where('published_at', '<=', now());
return $query->where('status', 'published')->whereNotNull('published_at')->where('published_at', '<=', now())
->whereRaw("COALESCE((SELECT origin.after_data->>'classification' FROM audit_events origin WHERE origin.source_system='opportunity-origin-review' AND origin.after_data->>'opportunity_id'=opportunities.id::text ORDER BY origin.occurred_at DESC,origin.id DESC LIMIT 1),'undetermined') <> 'example'");
}
}