Frontend Bug Fixes and Agent Data Investigation
Summary
This cluster documents a series of targeted fixes for the frontend search and analytics interface, specifically addressing percentage calculation errors, UI component behavior, and decile logic. It also identifies a data discrepancy in the agent database regarding agency affiliations.
Details
During a development session focused on the agent search and analytics interface, three primary frontend bugs were identified and resolved, and one data-level issue was investigated.
Frontend Fixes
-
Percentage Calculation Error (+725% vs +7.3%): A bug was identified in the display of the
delta_pctfield (lines 614-616). The backend API was already returning the spread as a percentage (e.g.,7.25). However, the frontend was multiplying this value by 100 again, resulting in inflated figures like 725%. The fix involved removing the redundant multiplication. -
Search Dropdown Persistence: The
AgentSearchInputcomponent’s dropdown menu was failing to close reliably after a result was selected. While theselectResultfunction (line 370) calledsetOpen(false), a race condition existed with anonBlurevent (line 410) that used asetTimeoutto close the menu. Furthermore, because the search results remained in the component state, the UI would often re-render the list. The resolution involved explicitly clearing the results state usingsetResults([])upon selection to ensure the dropdown exited the view. -
Decile Inversion Logic: A logic error in the decile ranking system was corrected. Previously, a decile ranking of 9 was being mapped to “20%” instead of the correct “80%”. This fix ensures that the percentile rankings accurately reflect the agent’s standing within the dataset.
Data Investigation: Snorri Björn Sturluson
An investigation was conducted into a reported discrepancy where the agent Snorri Björn Sturluson was displayed as being affiliated with Domusnova instead of Valhöll.
The investigation confirmed that the frontend was correctly displaying the data provided by the API. In the agents table, Snorri is mapped to agency_id 87 (Domusnova). This was determined to be a data quality issue—likely stale data from the extraction/ETL process—rather than a code bug. The developer noted that this requires a manual database correction or an update to the ETL pipeline rather than a frontend change.