Both workarounds existed because Five was missing two features that
just landed upstream:
Five 7629f95 (variadic PValue) makes FUNCTION foo(...) / PValue()
actually return the caller's variadic args instead of the caller's
first LOCAL slot. AP_RPUTS / AP_ECHO can go back to their `( ... )`
signature now.
Five f3e0ffe (file-local STATIC FUNCTION) gives each .prg its own
namespace for `STATIC FUNCTION name`, so the seven duplicate
`STATIC FUNCTION fn_HGet` definitions across labdb's api/*.prg
files no longer collide. The sed-renamed unique names can revert
to the upstream definitions.
Files
app/bridge/bridge_request.prg ← cp from fivenode/native/
app/api/{device-status,record-detail,records-list,session-detail,
session-stats,sessions-list,session-export}.prg
← cp from fivenode/labdb/api/
fivenode-upstream is now byte-identical to fivenode_go's app/ copy
of those files. No more "// fivenode_go patch" comments, no more
file-prefix renames.
Verified end-to-end against the same live postgres@16 cluster:
/api/admin-stats.prg -> {"active_sessions":1,"devices":2,...}
/api/sessions-list.prg -> 2 rows w/ full session data
/api/admin-devices.prg -> 2 devices w/ api_key, created_at
/api/hello.prg -> hello (unchanged)
/ -> 200 text/html (static)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
1.5 KiB
Plaintext
49 lines
1.5 KiB
Plaintext
// api/sessions-list.prg — Format session list response
|
|
//
|
|
// ctx inputs:
|
|
// rows (JSON string) — array of pg rows from server.js
|
|
// total (string number) — total count
|
|
// device_name (string) — current device name
|
|
//
|
|
// PRG handles formatting + Harbour float computation if needed.
|
|
// Copyright (c) 2026 Charles KWON OhJun
|
|
|
|
FUNCTION Main()
|
|
LOCAL aRows, hRow, aOut, hOut, nTotal, cDeviceName, hSession
|
|
|
|
aRows := hb_jsonDecode(ctx_get("rows", "[]"))
|
|
nTotal := Val(ctx_get("total", "0"))
|
|
cDeviceName := ctx_get("device_name", "")
|
|
|
|
IF ! HB_ISARRAY(aRows)
|
|
aRows := {}
|
|
ENDIF
|
|
|
|
aOut := {}
|
|
FOR EACH hRow IN aRows
|
|
hSession := { ;
|
|
"sessionId" => fn_HGet(hRow, "session_id"), ;
|
|
"sessionName" => fn_HGet(hRow, "session_name"), ;
|
|
"deviceName" => cDeviceName, ;
|
|
"startTime" => fn_HGet(hRow, "start_time"), ;
|
|
"endTime" => fn_HGet(hRow, "end_time"), ;
|
|
"recordCount" => fn_HGet(hRow, "record_count"), ;
|
|
"params" => fn_HGet(hRow, "params"), ;
|
|
"note" => fn_HGet(hRow, "note"), ;
|
|
"status" => fn_HGet(hRow, "status") ;
|
|
}
|
|
AAdd(aOut, hSession)
|
|
NEXT
|
|
|
|
hOut := { "total" => nTotal, "sessions" => aOut }
|
|
AP_JSONRESPONSE(hOut)
|
|
|
|
RETURN NIL
|
|
|
|
// Safe hash get (returns "" for missing key)
|
|
STATIC FUNCTION fn_HGet(hHash, cKey)
|
|
IF HB_ISHASH(hHash) .AND. hb_HHasKey(hHash, cKey)
|
|
RETURN hHash[ cKey ]
|
|
ENDIF
|
|
RETURN ""
|