fix: exclude closed tenders from upcoming feeds

This commit is contained in:
2026-09-06 14:26:31 +03:00
parent b2a416c908
commit c55257cade
4 changed files with 37 additions and 4 deletions
+3 -3
View File
@@ -6,6 +6,7 @@
// Claude Desktop (mcp-remote) araçları: search_tenders, get_tender,
// search_results, search_items, upcoming_deadlines. Bağımlılık yok.
import * as store from './user-store.mjs';
import { acikIhale } from '../src/services/ihaleTarih.js';
import { deadlineInfo, tenderDateKey } from '../src/services/tenderCalendar.js';
import { applyTenderStates, tenderStateKey } from '../src/services/tenderState.js';
import { readHistory, resultsByIkn } from './history-store.mjs';
@@ -36,8 +37,7 @@ export function trTarih(s) {
export function ihaleFiltrele(tenders, { q, il, sektor, sadeceAcik = true, limit = 50 } = {}, now = new Date()) {
const qq = norm(q); const ill = norm(il); const sek = norm(sektor);
return tenders
.filter((t) => !sadeceAcik || !t.kazananFirma)
.filter((t) => !sadeceAcik || deadlineInfo(t, now).expired !== true)
.filter((t) => !sadeceAcik || acikIhale(t, now))
.filter((t) => !ill || norm(t.sehir).includes(ill))
.filter((t) => !sek || norm(t.sektor).includes(sek))
.filter((t) => !qq || norm(t.baslik).includes(qq) || norm(t.kurum).includes(qq) || String(t.ikn ?? '').includes(qq) ||
@@ -106,7 +106,7 @@ export function yaklasanIhaleler(email, tenders, gun = 14, now = new Date()) {
const takip = new Set(store.getTrackedTenderKeys(email, states));
const days = Math.min(90, Math.max(1, Math.floor(Number(gun) || 14)));
return applyTenderStates(tenders, states)
.filter(t => !t.kazananFirma && takip.has(tenderStateKey(t)))
.filter(t => takip.has(tenderStateKey(t)) && acikIhale(t, now))
.map(t => ({ t, info: deadlineInfo(t, now) }))
.filter(({ info }) => info.days !== null && info.days >= 0 && info.days <= days && info.expired !== true)
.sort((a, b) => a.info.days - b.info.days ||