Skip to content

Commit

Permalink
Fix tooltips for TNS entries with empty internal_names field
Browse files Browse the repository at this point in the history
Some TNS entries do not have the `internal_names` response field
populated. For such entries, we would display the text "Not found"
in the tooltip. See, for example, AT2023qxj in
https://gcn.nasa.gov/circulars/34574.

For such TNS entries, use the TNS name itself as a default name
(in this example, "AT2023qxj").
  • Loading branch information
lpsinger committed Dec 5, 2024
1 parent 96e92bc commit d4c4647
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/routes/api.tooltip.tns.$.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,30 @@ export async function loader({ params: { '*': value } }: LoaderFunctionArgs) {
}

const {
objname,
name_prefix,
ra,
dec,
internal_names: names,
}: {
objname: string
name_prefix: string
ra?: string
dec?: string
internal_names?: string
} = (await response.json()).data.reply

if (!(ra && dec && names)) throw new Response(null, { status: 404 })
if (!(ra && dec)) throw new Response(null, { status: 404 })

return json(
{
ra: ra.split(splitter),
dec: dec.split(splitter),
// Some TNS events have values of `internal_names` that have an orphaned
// leading or trailing comma, such as `', PS24brk'`. Strip them out.
names: names.split(/\s*,\s*/).filter(Boolean),
names: (names || `${name_prefix}${objname}`)
.split(/\s*,\s*/)
.filter(Boolean),
},
{ headers: publicStaticShortTermCacheControlHeaders }
)
Expand Down

0 comments on commit d4c4647

Please sign in to comment.