From dca09e446bc898bfe03f8ba568f5b3e35039e341 Mon Sep 17 00:00:00 2001 From: phil Date: Thu, 30 Jan 2025 09:08:32 -0500 Subject: [PATCH] put $type in array path nothing is escaped, unclear how universal the $type convention is, etc. --- link_aggregator/readme.md | 13 ++++++++----- links/src/record.rs | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/link_aggregator/readme.md b/link_aggregator/readme.md index 0797f8f..a865021 100644 --- a/link_aggregator/readme.md +++ b/link_aggregator/readme.md @@ -90,12 +90,12 @@ some todos - [x] jetstream: don't rotate servers, explicitly pass via cli - [x] metrics! - [x] event ts lag -- [~] machine resource metrics +- [x] machine resource metrics - [x] disk consumption - [x] cpu usage - [x] mem usage - [x] network? -- [ ] make all storage apis return Result +- [ ] make all rocks apis return Result instead of unwrapping - [ ] handle all the unwraps - [ ] deadletter queue of some kind for failed db writes - [ ] also for valid json that was rejected? @@ -121,7 +121,10 @@ data fixes - [x] don't remove deleted links from the reverse records -- null them out. this will keep things stable for paging. - [x] don't show deactivated accounts in link responses - [ ] links: - - [ ] pull `$type`/`type` from object children of arrays (distinguish replies, quotes, etc) - - [ ] actually define the format (deal with in-band dots etc) - - [ ] _could_ throw cid neighbour into the target. probably should? but it's a lot of high volume uncompressible bytes + - [~] pull `$type`/`type` from object children of arrays (distinguish replies, quotes, etc) + - just $type to start + - [ ] rewrite the entire "path" stuff + - [ ] actually define the format (deal with in-band dots etc) + - [x] ~_could_ throw cid neighbour into the target. probably should? but it's a lot of high volume uncompressible bytes~ - and it could be looked up from the linker's doc + - ^^ for now, look up from source doc to get cid. might revisit this later. diff --git a/links/src/record.rs b/links/src/record.rs index 8d7f331..d83a171 100644 --- a/links/src/record.rs +++ b/links/src/record.rs @@ -10,9 +10,18 @@ pub fn walk_record(path: &str, v: &JsonValue, found: &mut Vec) { } } JsonValue::Array(a) => { - let p = format!("{path}[]"); for child in a { - walk_record(&p, child, found) + let child_p = match child { + JsonValue::Object(o) => { + if let Some(JsonValue::String(t)) = o.get("$type") { + format!("{path}[{t}]") + } else { + format!("{path}[]") + } + } + _ => format!("{path}[]"), + }; + walk_record(&child_p, child, found) } } JsonValue::String(s) => { @@ -145,7 +154,7 @@ mod tests { Link::Uri("https://youtu.be/oKXm4szEP1Q?si=_0n_uPu4qNKokMnq".into()), ), l( - ".facets[].features[].uri", + ".facets[].features[app.bsky.richtext.facet#link].uri", Link::Uri("https://youtu.be/oKXm4szEP1Q?si=_0n_uPu4qNKokMnq".into()), ), ] -- 2.51.2