perf + simpler: composite index, range-filtered protokoll, simpler profile
- Migration v9 adds idx_applications_user_flat_started on (user_id, flat_id, started_at DESC). Covers latest_applications_by_flat inner GROUP BY and the outer JOIN without a table scan. - Push the protokoll date range into SQL instead of pulling 5000 rows into Python and filtering there: new audit_in_range / errors_in_range helpers with a shared _range_filter_rows impl. Protokoll page limits 500, CSV export 5000. - _row_to_profile collapses to `dict(profile_row)`. ProfileModel (Pydantic) already validates and coerces types on the apply side, extras ignored. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
eb73b5e415
commit
cb617dd38a
3 changed files with 47 additions and 26 deletions
|
|
@ -7,25 +7,14 @@ logger = logging.getLogger("web.apply_client")
|
|||
|
||||
|
||||
def _row_to_profile(profile_row) -> dict:
|
||||
"""Convert a user_profiles row to the apply service Profile dict."""
|
||||
"""Convert a user_profiles row into the payload dict for /apply.
|
||||
|
||||
Apply-side ProfileModel (Pydantic) validates + coerces types; we just
|
||||
hand over whatever the row has. `updated_at` and any other extra keys
|
||||
are ignored by the model."""
|
||||
if profile_row is None:
|
||||
return {}
|
||||
keys = [
|
||||
"salutation", "firstname", "lastname", "email", "telephone",
|
||||
"street", "house_number", "postcode", "city",
|
||||
"is_possessing_wbs", "wbs_type", "wbs_valid_till",
|
||||
"wbs_rooms", "wbs_adults", "wbs_children", "is_prio_wbs",
|
||||
"immomio_email", "immomio_password",
|
||||
]
|
||||
d = {}
|
||||
for k in keys:
|
||||
try:
|
||||
d[k] = profile_row[k]
|
||||
except (KeyError, IndexError):
|
||||
pass
|
||||
for k in ("is_possessing_wbs", "is_prio_wbs"):
|
||||
d[k] = bool(d.get(k) or 0)
|
||||
return d
|
||||
return dict(profile_row)
|
||||
|
||||
|
||||
class ApplyClient:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue