fix(jobbank-search): emit date key derived from posted in search output (#342)

jobbank search output was missing the shared contract's date field; it now emits date as YYYY-MM-DD derived from posted (kept unchanged), null when the feed item has no pubDate. The inline result mapping is extracted into an exported normalizeSearchItem (behavior-preserving) so the derivation is pinned by tests.

Co-authored-by: oscarbol09 <80536682+oscarbol09@users.noreply.github.com>
This commit is contained in:
Oscar Madera
2026-08-19 08:32:49 +02:00
committed by GitHub
parent 17bc698697
commit df7919cdf5
3 changed files with 60 additions and 17 deletions
@@ -1,6 +1,24 @@
import { defineCommand, option } from "@bunli/core"
import { z } from "zod"
import { rssFetch, fetchWithUA, writeError, parseRssDescription, extractJobIdFromUrl, BASE_URL } from "../helpers.js"
import { rssFetch, fetchWithUA, writeError, parseRssDescription, extractJobIdFromUrl, BASE_URL, type RssItem } from "../helpers.js"
export function normalizeSearchItem(item: RssItem): Record<string, unknown> {
const parsed = parseRssDescription(item.description)
const id = extractJobIdFromUrl(item.link)
const posted = item.pubDate ? new Date(item.pubDate).toISOString() : ""
return {
id,
title: item.title,
company: parsed.company,
location: parsed.location,
jobType: parsed.jobType,
description: item.description,
url: item.link,
posted,
date: posted ? posted.slice(0, 10) : null,
deadline: parsed.deadline,
}
}
export const search = defineCommand({
name: "search",
@@ -134,22 +152,7 @@ export const search = defineCommand({
}
// Normalize items
let results = items.map((item) => {
const parsed = parseRssDescription(item.description)
const id = extractJobIdFromUrl(item.link)
const posted = item.pubDate ? new Date(item.pubDate).toISOString() : ""
return {
id,
title: item.title,
company: parsed.company,
location: parsed.location,
jobType: parsed.jobType,
description: item.description,
url: item.link,
posted,
deadline: parsed.deadline,
}
})
let results = items.map(normalizeSearchItem)
// Apply limit
if (flags.limit !== undefined) {