Skip to content

Add origin id field to actor and bulletin searchbox#140

Merged
tarekio merged 7 commits intomainfrom
BYNT-1402-Add-Origin-ID-search-to-Bulletins-and-Actors-frontend
Sep 7, 2025
Merged

Add origin id field to actor and bulletin searchbox#140
tarekio merged 7 commits intomainfrom
BYNT-1402-Add-Origin-ID-search-to-Bulletins-and-Actors-frontend

Conversation

@apodacaduron
Copy link
Contributor

@apodacaduron apodacaduron commented Jul 18, 2025

Jira Issue

  1. BYNT-1402
  2. BYNT-1401

Description

Add new search field to search Origin ID in Actors and Bulletin advanced search dialog.

Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • New strings prepared for translations

API Changes (if applicable)

  • Permissions checked
  • Endpoint tests added

Additional Notes

[Any other relevant information]

Summary by CodeRabbit

  • New Features
    • Introduces an Origin ID filter across bulletin and actor searches with case-insensitive matching.
    • Actor search box now includes an Origin ID field, replacing the previous “Not Contains” text input.
    • Actor results can be filtered by Origin ID present in any linked profile.
    • Bulletin results support partial Origin ID matches.
    • Existing search filters and behavior remain unchanged, preserving current workflows.

@apodacaduron apodacaduron self-assigned this Jul 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 5, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds optional originid filter support end-to-end: new optional originid fields in validation/query models, replaces Actor “Not Contains” UI input with “Origin Id”, and updates backend search utilities to filter bulletins and actors by originid.

Changes

Cohort / File(s) Summary
Validation models
enferno/admin/validation/models.py
Adds optional string field originid to BulletinQueryValidationModel and ActorQueryModel; no other logic changed.
Frontend search input
enferno/static/js/components/ActorSearchBox.js
Replaces “Not Contains” (extsv) input with “Origin Id” input bound to q.originid; labels updated; component flow unchanged.
Search filtering
enferno/utils/search_utils.py
Adds originid-based filters: bulletins filter by Bulletin.originid.ilike('%...%'); actors filter via related ActorProfile.originid.ilike('%...%'). Existing filters unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as ActorSearchBox (UI)
  participant API as Server (Search Endpoint)
  participant DB as Database

  User->>UI: Enter Origin Id
  UI->>API: GET /actors?q.originid=...
  API->>DB: Query Actor join ActorProfile<br/>WHERE ActorProfile.originid ILIKE %originid%
  DB-->>API: Matching actors
  API-->>UI: Results
  UI-->>User: Display filtered actors

  Note over API,DB: Similar flow for Bulletins using Bulletin.originid ILIKE %originid%
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my ears at origin’s thread,
A trail of IDs softly spread—
From models stitched to searches keen,
The burrow maps what’s in-between.
With one new key, the paths align;
I thump: results! So crisp, so fine. 🥕

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch BYNT-1402-Add-Origin-ID-search-to-Bulletins-and-Actors-frontend

Comment @coderabbitai help to get the list of available commands and usage tips.

@tarekio tarekio self-assigned this Sep 5, 2025
@tarekio tarekio marked this pull request as ready for review September 5, 2025 21:55
@tarekio
Copy link
Contributor

tarekio commented Sep 5, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Sep 5, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
enferno/static/js/components/ActorSearchBox.js (1)

138-142: Trim and harden Origin ID input (i18n key verified)
Translation key originId_ is defined in jsapi.jinja2. Apply the below to trim input, disable browser heuristics, and cap length:

-              <v-text-field
-                  v-model="q.originid"
-                  :label="translations.originId_"
-                  clearable
-              ></v-text-field>
+              <v-text-field
+                  v-model.trim="q.originid"
+                  :label="translations.originId_"
+                  autocomplete="off"
+                  autocapitalize="off"
+                  autocorrect="off"
+                  spellcheck="false"
+                  maxlength="255"
+                  :counter="255"
+                  clearable
+              ></v-text-field>
enferno/utils/search_utils.py (2)

193-198: Bulletin originid filter works; prefer exact match when possible for index use.

IDs are typically tokens; using ILIKE with surrounding wildcards can defeat indexes. Use exact ILIKE when the user doesn’t intend substring search.

Apply:

-        originid = q.get("originid")
-        if originid:
-            condition = Bulletin.originid.ilike(f"%{originid}%")
-            conditions.append(condition)
+        originid = (q.get("originid") or "").strip()
+        if originid:
+            # Exact (case-insensitive) match for token-like IDs; fallback to substring for longer probes
+            condition = (
+                Bulletin.originid.ilike(originid)
+                if len(originid) < 3 or not originid.isalnum()
+                else Bulletin.originid.ilike(f"%{originid}%")
+            )
+            conditions.append(condition)

512-517: Actor originid filter OK; mirror the exact-then-substring strategy.

Keeps behavior intuitive and can leverage indexes for common exact-ID lookups.

-        originid = q.get("originid")
-        if originid:
-            condition = Actor.actor_profiles.any(ActorProfile.originid.ilike(f"%{originid}%"))
-            conditions.append(condition)
+        originid = (q.get("originid") or "").strip()
+        if originid:
+            cond = (
+                ActorProfile.originid.ilike(originid)
+                if len(originid) < 3 or not originid.isalnum()
+                else ActorProfile.originid.ilike(f"%{originid}%")
+            )
+            conditions.append(Actor.actor_profiles.any(cond))
enferno/admin/validation/models.py (2)

1197-1197: Cap BulletinQueryValidationModel.originid length.

Prevents excessively long user inputs from impacting query planning.

-    originid: Optional[str] = None
+    originid: Optional[str] = Field(default=None, max_length=255)

1332-1332: Cap ActorQueryModel.originid length.

Same rationale as above.

-    originid: Optional[str] = None
+    originid: Optional[str] = Field(default=None, max_length=255)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge Base: Disabled due to data retention organization setting

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 111cf36 and 37ba549.

📒 Files selected for processing (3)
  • enferno/admin/validation/models.py (2 hunks)
  • enferno/static/js/components/ActorSearchBox.js (1 hunks)
  • enferno/utils/search_utils.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test

@tarekio tarekio requested a review from level09 September 6, 2025 15:40
Copy link
Collaborator

@level09 level09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. let's use the originid_ translation consistently, currently we have two duplicates of the same string, but since we have too many duplicates I suggest a separate PR for this
  2. Since we are doing Partial matching with %string% , our current database index on originid (B-tree) is useless and won't be hit. let's create a migration to use a trigram index that will be utilized effectively with partial match.

@tarekio
Copy link
Contributor

tarekio commented Sep 7, 2025

  1. let's use the originid_ translation consistently, currently we have two duplicates of the same string, but since we have too many duplicates I suggest a separate PR for this
  2. Since we are doing Partial matching with %string% , our current database index on originid (B-tree) is useless and won't be hit. let's create a migration to use a trigram index that will be utilized effectively with partial match.

Agree with first comment, let's address in a separate PR. Second comment addressed.

@tarekio tarekio merged commit 39ffb2a into main Sep 7, 2025
8 checks passed
@tarekio tarekio deleted the BYNT-1402-Add-Origin-ID-search-to-Bulletins-and-Actors-frontend branch September 7, 2025 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants