fix(scrape): address residual review findings R1–R3

Use padded sort for last_message_id cursor, surface guild channel
discovery errors, and document DCE_ARCHIVE_ROOT in compose.
This commit is contained in:
Boden
2026-05-29 13:56:29 -05:00
parent c713ee5e64
commit 25e1a7e600
3 changed files with 65 additions and 4 deletions

View File

@@ -374,7 +374,16 @@ last_message_id() {
[[ -f "$export_path" ]] || return 0
jq -r '
(.messages // [])
| if length == 0 then empty else (max_by(.id) | .id) end
| if length == 0 then empty else (
sort_by(
.id as $id
| ($id | tostring) as $s
| (22 - ($s | length)) as $pad
| if $pad > 0 then ("0" * $pad) + $s else $s end
)
| last
| .id
) end
' "$export_path"
}
@@ -508,11 +517,15 @@ load_guild_channel_cache() {
local cache_file="$CACHE_ROOT/channels_${guild_id}_${include_voice}_${include_threads}.txt"
if [[ ! -f "$cache_file" ]]; then
"$CLI_BIN" channels \
local output
if ! output=$("$CLI_BIN" channels \
--guild "$guild_id" \
--include-vc "$include_voice" \
--include-threads "$include_threads" \
| parse_channel_listing >"$cache_file"
--include-threads "$include_threads" 2>&1); then
die "Channel discovery failed for guild $guild_id. CLI output: $output"
fi
printf '%s\n' "$output" | parse_channel_listing >"$cache_file"
fi
cat "$cache_file"