CPV/OKAS ham kod sınıflandırması: yayınlanmadan önce tamamlanan bir gate + sidebar filtresi

- server/cpv-classify.mjs (yeni): existing (kalem kodu) → keyword (66 kural, 45 OKAS_BOLUM kodunun tamamı kapsanıyor) → AI (analyzeSpec, sadece sözlükte gerçekten var olan kod kabul edilir) hibrit sınıflandırma
- server/index.js: cache.tenders'a eklenmeden ÖNCE her ihale için CPV sınıflandırması await'leniyor (mevcut "sektör" alanının aksine, sonradan zenginleştirilmiyor) — hem ilk yükleme hem arka plan tamamlama yolunda
- İKN bazlı kalıcı SQLite önbellek (history-store.mjs) — aynı ilan bir daha asla yeniden sınıflandırılmıyor
- /api/meta/filtreler artık cpvBolumler döndürüyor
- Frontend: Sektörler'in hemen altına CPV Kodu filtresi (arama + çoklu seçim), ihale kartında CPV rozeti, landing page'de yeni özellik: "AB uyumlu CPV sınıflandırması — Türkiye'de ilk"
This commit is contained in:
2026-08-30 14:00:56 +03:00
parent f98568da8e
commit c5662d2e60
10 changed files with 490 additions and 15 deletions
+62 -2
View File
@@ -3,7 +3,7 @@ import { useApp } from '../context/AppContext';
import { INSTITUTION_TYPES_LIST, CITIES_LIST } from '../data/constants';
import {
Compass, Zap, Wrench, Calendar, Eye, EyeOff, FileText, CheckCircle2, XCircle, Archive,
Bot, PlusCircle, Trash2, ChevronDown, ChevronUp, Filter, MapPin, Building2, Tag, Star
Bot, PlusCircle, Trash2, ChevronDown, ChevronUp, Filter, MapPin, Building2, Tag, Star, Hash
} from 'lucide-react';
export const LeftSidebar = () => {
@@ -20,6 +20,10 @@ export const LeftSidebar = () => {
setSelectedSektorler,
toggleSektor,
sektorListesi,
selectedCpvler,
setSelectedCpvler,
toggleCpv,
cpvBolumListesi,
selectedKurumTipi,
setSelectedKurumTipi,
selectedCity,
@@ -28,9 +32,11 @@ export const LeftSidebar = () => {
} = useApp();
const [sektorAra, setSektorAra] = useState('');
const [cpvAra, setCpvAra] = useState('');
const [openSections, setOpenSections] = useState({
alimTuru: true,
sektorler: true,
cpv: false,
kurumTipleri: false,
iller: false
});
@@ -62,7 +68,7 @@ export const LeftSidebar = () => {
<span className="font-bold text-xs uppercase tracking-wider text-slate-700 flex items-center gap-1.5">
<Compass className="w-4 h-4 text-blue-600" /> Hızlı Erişim
</span>
{(quickFilter !== 'all' || selectedSektorler.length || selectedCity || selectedAlimTuru || selectedKurumTipi) && (
{(quickFilter !== 'all' || selectedSektorler.length || selectedCpvler.length || selectedCity || selectedAlimTuru || selectedKurumTipi) && (
<button
onClick={clearAllFilters}
className="text-[11px] font-medium text-blue-600 hover:underline"
@@ -242,6 +248,60 @@ export const LeftSidebar = () => {
)}
</div>
{/* CPV Kodu */}
<div>
<button
onClick={() => toggleSection('cpv')}
className="w-full px-4 py-3 flex items-center justify-between text-xs font-bold text-slate-800 bg-slate-50/50 hover:bg-slate-100 transition-colors"
>
<span className="flex items-center gap-2">
<Hash className="w-4 h-4 text-blue-600" /> CPV Kodu
</span>
{openSections.cpv ? <ChevronUp className="w-4 h-4 text-slate-400" /> : <ChevronDown className="w-4 h-4 text-slate-400" />}
</button>
{openSections.cpv && (
<div className="p-3 space-y-1 text-xs">
<p className="text-[11px] text-slate-500 mb-2 leading-relaxed">
CPV, AB'nin ihale konusunu sınıflandırdığı standart koddur. Türkiye'deki NACE/faaliyet kodunun yerine geçmez — NACE firmanızı, CPV ihalenin konusunu sınıflandırır.
</p>
<input
value={cpvAra}
onChange={(e) => setCpvAra(e.target.value)}
placeholder="CPV ara…"
className="w-full border border-slate-200 rounded-lg px-2 py-1.5 mb-1 text-xs focus:outline-hidden focus:ring-2 focus:ring-blue-500/30"
/>
<div className="max-h-56 overflow-y-auto space-y-1">
<button
onClick={() => { setSelectedCpvler([]); setActiveTab('list'); }}
className={`w-full text-left px-2 py-1 rounded font-medium ${!selectedCpvler.length ? 'bg-blue-50 text-blue-700 font-bold' : 'text-slate-600 hover:bg-slate-50'}`}
>
Tüm CPV Kodları {selectedCpvler.length > 0 && <span className="text-slate-400">({selectedCpvler.length} seçili)</span>}
</button>
{/* Çoklu seçim: kutucuklar birikir, liste kapanmaz */}
{cpvBolumListesi
.filter((c) => c.kod.includes(cpvAra) || c.etiket.toLocaleLowerCase('tr').includes(cpvAra.toLocaleLowerCase('tr')))
.map(c => {
const secili = selectedCpvler.includes(c.kod);
return (
<label
key={c.kod}
className={`flex items-center gap-2 px-2 py-1 rounded cursor-pointer font-medium ${secili ? 'bg-blue-50 text-blue-700 font-bold' : 'text-slate-600 hover:bg-slate-50'}`}
>
<input
type="checkbox"
checked={secili}
onChange={() => { toggleCpv(c.kod); setActiveTab('list'); }}
className="accent-blue-600 shrink-0"
/>
<span className="truncate">{c.kod} — {c.etiket}</span>
</label>
);
})}
</div>
</div>
)}
</div>
{/* Kurum Tipleri */}
<div>
<button