Repository navigation
fix(customer-master): open related posts in place instead of jumping to Board #414
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
Changes from 4 commits
5e37378
d5d6668
a046da4
b4f12bc
119212e
4edf12d
8684d68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,7 @@ | |
| from backend.app.post_eligibility import ( | ||
| SOURCE_POST_ELIGIBILITY_SQL, | ||
| SOURCE_POST_READER_ELIGIBILITY_SQL, | ||
| SOURCE_POST_VISIBILITY_SQL, | ||
| WRITING_SOURCE_DETAIL_STATE_CODE, | ||
| normalize_source_detail_state_code, | ||
| source_post_state_visibility_sql, | ||
|
|
@@ -829,12 +830,15 @@ def _observed_hierarchy_ids(rows: list[asyncpg.Record]) -> set[str]: | |
|
|
||
| @app.get("/api/customer-master") | ||
| async def read_customer_master( | ||
| hint_code: str | None = Query(default=None, max_length=255), | ||
| account: CurrentAccount = Depends(get_current_account), | ||
| pool: asyncpg.Pool = Depends(get_pool), | ||
| ) -> dict[str, Any]: | ||
| """Return the authorized customer catalog and its cataloged Keymen.""" | ||
| _require_post_read(account) | ||
| if not account.corporate_entity_ids: | ||
| requested_hint_code = (hint_code or "").strip() or None | ||
| authorized_entity_ids = list(account.corporate_entity_ids) | ||
| if not authorized_entity_ids: | ||
| return { | ||
| "corporate_entities": [], | ||
| "keymen": [], | ||
|
|
@@ -857,8 +861,10 @@ async def read_customer_master( | |
| from source_post | ||
| where (nullif(btrim(source_customer_code), '') is not null | ||
| or nullif(btrim(source_customer_name), '') is not null) | ||
| and (visibility_code = 'public' or corporate_entity_id = any($1::uuid[])) | ||
| and {SOURCE_POST_ELIGIBILITY_SQL.format(alias='source_post')} | ||
| and ($2::text is null | ||
| or nullif(btrim(source_customer_code), '') = $2::text) | ||
| and {SOURCE_POST_VISIBILITY_SQL.format(alias='source_post', authorized_entity_ids='$1')} | ||
| and {SOURCE_POST_ELIGIBILITY_SQL.format(alias='source_post')} | ||
|
Comment on lines
+864
to
+867
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Visibility SQL refactor is behavior-preserving The customer-rows query swaps its inline visibility clause for Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| ), ranked as ( | ||
| select scoped.*, | ||
| row_number() over ( | ||
|
|
@@ -902,7 +908,8 @@ async def read_customer_master( | |
| and related.customer_name_group is not distinct from top_groups.customer_name_group | ||
| order by top_groups.post_count desc, top_groups.customer_code, top_groups.customer_name | ||
| """, | ||
| list(account.corporate_entity_ids), | ||
| authorized_entity_ids, | ||
| requested_hint_code, | ||
| ) | ||
| # Safe SQL: the evidence query uses only closed schema fragments; authorized entity ids are bound. | ||
| source_author_rows = await conn.fetch( # nosemgrep: python.lang.security.audit.sqli.asyncpg-sqli.asyncpg-sqli | ||
|
|
||
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.
📝 Info: Hint filter forces an extra source-context query
has_source_contextis derived from the (now hint-filtered)source_customer_rows, so a filtered request that matches no code triggers thehas_real_source_contextfallback query (main.py). The fallback is global, so the result is unchanged, but an extra DB round-trip runs per filtered request.(Refers to this code)
Was this helpful? React with 👍 or 👎 to provide feedback.