Conversation
…and-Actors-frontend
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds 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
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%
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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 keyoriginId_is defined injsapi.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.
📒 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
level09
left a comment
There was a problem hiding this comment.
- 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
- 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. |
…and-Actors-frontend
Jira Issue
Description
Add new search field to search Origin ID in Actors and Bulletin advanced search dialog.
Checklist
API Changes (if applicable)
Additional Notes
[Any other relevant information]
Summary by CodeRabbit