fix(pres_mgmt): use tmp_sort_2 for presentation sort in Pres Mgmt and Launcher

Compute presentation-specific tmp_sort_1/tmp_sort_2 in specific_processor,
overriding the generic values from _process_generic_props which had two bugs:
- priority encoded as 0/1 ASC (backwards — true should sort first)
- sort stored as unpadded string ("10" < "2" lexicographically)
- start_datetime and code not included (presentation-specific fields)

New encoding: priority(inv)_sort(8-padded)_start_datetime_code[_name]
Both liveQueries (Pres Mgmt session page, Launcher session view) now use
.sortBy('tmp_sort_2') — cleaner and uses the indexed field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-05-28 20:20:50 -04:00
parent 35fed53e2a
commit 182a066d38
3 changed files with 22 additions and 53 deletions

View File

@@ -680,6 +680,20 @@ export async function process_ae_obj__event_presentation_props({
if (obj.event_session_id_random)
obj.event_session_id = obj.event_session_id_random;
if (obj.event_id_random) obj.event_id = obj.event_id_random;
// Override generic tmp_sort_* with presentation-specific encoding.
// WHY: Generic _process_generic_props encodes priority as 0/1 ASC (backwards)
// and sort as an unpadded string ("10" < "2"). Presentations also need
// start_datetime and code in the sort chain, which are not generic fields.
// Desired order: priority DESC → sort ASC → start_datetime ASC → code ASC → name ASC
// Encoding trick: invert priority so true→'0' sorts before false→'1' ascending.
const p = obj.priority ? '0' : '1';
const s = String(Number(obj.sort ?? 0)).padStart(8, '0');
const dt = obj.start_datetime ?? '';
const code = obj.code ?? '';
const name = obj.name ?? '';
obj.tmp_sort_1 = `${p}_${s}_${dt}_${code}`;
obj.tmp_sort_2 = `${p}_${s}_${dt}_${code}_${name}`;
return obj;
}
});