docs(s011): bölüm video hattı, S-009 Faz 0 içerik ve 17 Eki raporları (yerel çalışma)
Pull öncesi yerel çalışma ağacındaki iş commit'e alındı; data/app.db dışarıda. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
271
scripts/bolum-icerik-denetim.ts
Normal file
271
scripts/bolum-icerik-denetim.ts
Normal file
@@ -0,0 +1,271 @@
|
||||
/**
|
||||
* Bölüm içeriği denetimi — docs/spec/S-009 §3.2 şeması ve §3.4 kalite kapısı.
|
||||
* `pnpm bolum:denetim` (pnpm lint zincirinde). Kapsam: content/bolum/*.md.
|
||||
*
|
||||
* Çıkış kodu: hata varsa 1, yoksa 0. Uyarılar çıkış kodunu etkilemez.
|
||||
*
|
||||
* Çalıştırma: `tsx --conditions=react-server` — src/lib/katalog.ts
|
||||
* "server-only" taşır; react-server koşulunda o paket boş modüle çözülür.
|
||||
*
|
||||
* Kontroller (S-009 §3.2, §3.3, §3.4):
|
||||
* - frontmatter var ve yalnız şemadaki anahtarları taşır
|
||||
* - slug = dosya adı, katalogda var (src/lib/katalog.ts); ad katalogla aynı
|
||||
* - duzey lisans|onlisans ve katalogdaki düzeyle uyumlu
|
||||
* - ozet ≤ 160 karakter, tek cümle
|
||||
* - ne_ogrenir / mezun_olunca tam 3 madde (kaynak açılamadıysa boş liste → uyarı),
|
||||
* her madde ≤ 8 kelime ve var olan bir `kaynak` numarası taşır
|
||||
* - kaynaklar ≥ 2, numaralar tekil, URL https ve alan adı izinli listede, erisim tarihi
|
||||
* - guncelleme tarihi
|
||||
* - yasak sözcükler (ozet, maddeler, gövde)
|
||||
* - gövde ≤ 60 kelime
|
||||
*/
|
||||
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
||||
import { basename, join, relative } from "node:path";
|
||||
import { getAllBolumSlugs, getBolumBySlug } from "../src/lib/katalog";
|
||||
|
||||
type Seviye = "hata" | "uyari";
|
||||
type Bulgu = { dosya: string; seviye: Seviye; kural: string; mesaj: string };
|
||||
|
||||
const KOK = process.cwd();
|
||||
const DIZIN = join(KOK, "content", "bolum");
|
||||
|
||||
/** S-009 §3.3 — izinli alan adları. Ekleme [BİLAL]. */
|
||||
const IZINLI_ALANLAR = [
|
||||
"portal.tyc.gov.tr",
|
||||
"yokatlas.yok.gov.tr",
|
||||
"osym.gov.tr",
|
||||
"tuik.gov.tr",
|
||||
"myk.gov.tr",
|
||||
"iskur.gov.tr",
|
||||
];
|
||||
const IZINLI_SONEKLER = [".edu.tr"];
|
||||
|
||||
/** S-009 §3.4 + rol dosyası "Dil" — yasak sözcükler. Kök eşleşenler ek alabilir. */
|
||||
const YASAK_KOK = ["garanti", "prestij", "popüler"];
|
||||
const YASAK_SOZCUK = ["kesin", "yerleşirsin", "kolay", "en iyi", "geleceğin mesleği", "iş garantisi"];
|
||||
|
||||
const ZORUNLU_ANAHTARLAR = ["slug", "ad", "duzey", "ozet", "ne_ogrenir", "mezun_olunca", "kaynaklar", "guncelleme"];
|
||||
const TARIH = /^\d{4}-\d{2}-\d{2}$/;
|
||||
|
||||
type Madde = Record<string, string>;
|
||||
type Frontmatter = Record<string, string | Madde[]>;
|
||||
|
||||
// ---------- Frontmatter ayrıştırma (yalnız §3.2 biçimi; gray-matter yok) ----------
|
||||
|
||||
function tirnakSoy(v: string): string {
|
||||
const t = v.trim();
|
||||
if ((t.startsWith('"') && t.endsWith('"')) || (t.startsWith("'") && t.endsWith("'"))) {
|
||||
return t.slice(1, -1);
|
||||
}
|
||||
// Tırnaksız değerde satır sonu yorumu
|
||||
return t.replace(/\s+#.*$/, "").trim();
|
||||
}
|
||||
|
||||
/** `{ metin: "…", kaynak: 1 }` → nesne. Tırnak içindeki virgülü böler, dışındakini ayırır. */
|
||||
function satirIciNesne(s: string): Madde | null {
|
||||
const ic = s.trim();
|
||||
if (!ic.startsWith("{") || !ic.endsWith("}")) return null;
|
||||
const govde = ic.slice(1, -1);
|
||||
const parcalar: string[] = [];
|
||||
let tampon = "";
|
||||
let tirnak: string | null = null;
|
||||
for (const ch of govde) {
|
||||
if (tirnak) {
|
||||
tampon += ch;
|
||||
if (ch === tirnak) tirnak = null;
|
||||
} else if (ch === '"' || ch === "'") {
|
||||
tirnak = ch;
|
||||
tampon += ch;
|
||||
} else if (ch === ",") {
|
||||
parcalar.push(tampon);
|
||||
tampon = "";
|
||||
} else tampon += ch;
|
||||
}
|
||||
if (tampon.trim()) parcalar.push(tampon);
|
||||
const sonuc: Madde = {};
|
||||
for (const p of parcalar) {
|
||||
const i = p.indexOf(":");
|
||||
if (i === -1) return null;
|
||||
sonuc[p.slice(0, i).trim()] = tirnakSoy(p.slice(i + 1));
|
||||
}
|
||||
return sonuc;
|
||||
}
|
||||
|
||||
function frontmatterAyristir(ham: string): { fm: Frontmatter; govde: string; hata?: string } {
|
||||
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(ham);
|
||||
if (!m) return { fm: {}, govde: "", hata: "frontmatter bulunamadı (--- … ---)" };
|
||||
const fm: Frontmatter = {};
|
||||
let listeAnahtari: string | null = null;
|
||||
for (const satirHam of m[1].split(/\r?\n/)) {
|
||||
const satir = satirHam.replace(/\s+$/, "");
|
||||
if (!satir.trim() || satir.trim().startsWith("#")) continue;
|
||||
const liste = /^\s+-\s+(.*)$/.exec(satir);
|
||||
if (liste) {
|
||||
if (!listeAnahtari) return { fm, govde: "", hata: `liste öğesi anahtarsız: "${satir.trim()}"` };
|
||||
const nesne = satirIciNesne(liste[1]);
|
||||
if (!nesne) return { fm, govde: "", hata: `liste öğesi { … } biçiminde değil: "${satir.trim()}"` };
|
||||
(fm[listeAnahtari] as Madde[]).push(nesne);
|
||||
continue;
|
||||
}
|
||||
const kv = /^([a-z_]+):\s*(.*)$/.exec(satir);
|
||||
if (!kv) return { fm, govde: "", hata: `tanınmayan satır: "${satir.trim()}"` };
|
||||
const [, anahtar, deger] = kv;
|
||||
const temiz = deger.replace(/^\s*#.*$/, "").trim();
|
||||
if (temiz === "" || temiz === "[]") {
|
||||
fm[anahtar] = [];
|
||||
listeAnahtari = anahtar;
|
||||
} else {
|
||||
fm[anahtar] = tirnakSoy(deger);
|
||||
listeAnahtari = null;
|
||||
}
|
||||
}
|
||||
return { fm, govde: m[2].trim() };
|
||||
}
|
||||
|
||||
// ---------- Yardımcılar ----------
|
||||
|
||||
function kelimeSayisi(s: string): number {
|
||||
return s.trim() ? s.trim().split(/\s+/).length : 0;
|
||||
}
|
||||
|
||||
const HARF = "a-zçğıöşüâîû";
|
||||
function yasakSozcukler(metin: string): string[] {
|
||||
const k = metin.toLocaleLowerCase("tr-TR");
|
||||
const bulunan: string[] = [];
|
||||
for (const kok of YASAK_KOK) {
|
||||
if (new RegExp(`(^|[^${HARF}])${kok}`, "u").test(k)) bulunan.push(kok);
|
||||
}
|
||||
for (const soz of YASAK_SOZCUK) {
|
||||
if (new RegExp(`(^|[^${HARF}])${soz}([^${HARF}]|$)`, "u").test(k)) bulunan.push(soz);
|
||||
}
|
||||
return bulunan;
|
||||
}
|
||||
|
||||
function alanAdiIzinli(url: string): { ok: boolean; neden?: string } {
|
||||
let u: URL;
|
||||
try {
|
||||
u = new URL(url);
|
||||
} catch {
|
||||
return { ok: false, neden: "geçersiz URL" };
|
||||
}
|
||||
if (u.protocol !== "https:") return { ok: false, neden: "https değil" };
|
||||
const h = u.hostname.toLowerCase();
|
||||
const izinli =
|
||||
IZINLI_ALANLAR.some((a) => h === a || h.endsWith("." + a)) ||
|
||||
IZINLI_SONEKLER.some((s) => h.endsWith(s));
|
||||
return izinli ? { ok: true } : { ok: false, neden: `alan adı izinli listede değil: ${h}` };
|
||||
}
|
||||
|
||||
// ---------- Denetim ----------
|
||||
|
||||
const bulgular: Bulgu[] = [];
|
||||
const katalogSluglar = new Set(getAllBolumSlugs());
|
||||
|
||||
function dosyaDenetle(yol: string) {
|
||||
const dosya = relative(KOK, yol);
|
||||
const hata = (kural: string, mesaj: string) => bulgular.push({ dosya, seviye: "hata", kural, mesaj });
|
||||
const uyari = (kural: string, mesaj: string) => bulgular.push({ dosya, seviye: "uyari", kural, mesaj });
|
||||
|
||||
const { fm, govde, hata: ayristirmaHatasi } = frontmatterAyristir(readFileSync(yol, "utf8"));
|
||||
if (ayristirmaHatasi) {
|
||||
hata("frontmatter", ayristirmaHatasi);
|
||||
return;
|
||||
}
|
||||
|
||||
// Anahtar kümesi (§3.2)
|
||||
for (const a of ZORUNLU_ANAHTARLAR) if (!(a in fm)) hata("sema", `zorunlu alan yok: ${a}`);
|
||||
for (const a of Object.keys(fm)) if (!ZORUNLU_ANAHTARLAR.includes(a)) hata("sema", `şemada olmayan alan: ${a}`);
|
||||
|
||||
const metin = (a: string): string => (typeof fm[a] === "string" ? (fm[a] as string) : "");
|
||||
const liste = (a: string): Madde[] => (Array.isArray(fm[a]) ? (fm[a] as Madde[]) : []);
|
||||
|
||||
// slug / ad / duzey — katalog tek kaynak
|
||||
const slug = metin("slug");
|
||||
const dosyaSlug = basename(yol, ".md");
|
||||
if (slug !== dosyaSlug) hata("slug", `slug "${slug}" dosya adıyla ("${dosyaSlug}") aynı değil`);
|
||||
if (!katalogSluglar.has(dosyaSlug)) {
|
||||
hata("slug", `katalogda böyle bölüm yok: ${dosyaSlug} (src/lib/katalog.ts / data/yokatlas.db)`);
|
||||
} else {
|
||||
const b = getBolumBySlug(dosyaSlug)!;
|
||||
if (metin("ad") !== b.ad) hata("ad", `ad "${metin("ad")}" katalogdaki adla ("${b.ad}") aynı değil`);
|
||||
const duzey = metin("duzey");
|
||||
if (duzey !== "lisans" && duzey !== "onlisans") hata("duzey", `duzey lisans|onlisans olmalı: "${duzey}"`);
|
||||
else if (duzey === "lisans" && !b.lisans) hata("duzey", "duzey lisans ama katalogda lisans programı yok");
|
||||
else if (duzey === "onlisans" && !b.onlisans) hata("duzey", "duzey onlisans ama katalogda önlisans programı yok");
|
||||
}
|
||||
|
||||
// ozet
|
||||
const ozet = metin("ozet");
|
||||
if (!ozet) hata("ozet", "ozet boş");
|
||||
else {
|
||||
if (ozet.length > 160) hata("ozet", `ozet ${ozet.length} karakter (en çok 160)`);
|
||||
const govdeNokta = /[.!?](?=.)/.test(ozet.replace(/\b(vb|vs|dr|prof)\./gi, "$1"));
|
||||
if (govdeNokta) hata("ozet", "ozet tek cümle olmalı (ortada nokta/ünlem/soru işareti var)");
|
||||
}
|
||||
|
||||
// kaynaklar
|
||||
const kaynaklar = liste("kaynaklar");
|
||||
const kaynakNolar = new Set<number>();
|
||||
if (kaynaklar.length < 2) hata("kaynak", `en az 2 kaynak gerekli, ${kaynaklar.length} var`);
|
||||
kaynaklar.forEach((k, i) => {
|
||||
const no = Number(k.no);
|
||||
if (!Number.isInteger(no) || no < 1) hata("kaynak", `kaynak ${i + 1}: "no" pozitif tam sayı olmalı`);
|
||||
else if (kaynakNolar.has(no)) hata("kaynak", `kaynak no ${no} birden fazla kez tanımlı`);
|
||||
else kaynakNolar.add(no);
|
||||
if (!k.ad?.trim()) hata("kaynak", `kaynak ${no}: "ad" boş`);
|
||||
if (!k.url) hata("kaynak", `kaynak ${no}: "url" boş`);
|
||||
else {
|
||||
const a = alanAdiIzinli(k.url);
|
||||
if (!a.ok) hata("kaynak", `kaynak ${no}: ${a.neden} (S-009 §3.3)`);
|
||||
}
|
||||
if (!TARIH.test(k.erisim ?? "")) hata("kaynak", `kaynak ${no}: "erisim" YYYY-AA-GG biçiminde olmalı`);
|
||||
});
|
||||
|
||||
// ne_ogrenir / mezun_olunca
|
||||
for (const alan of ["ne_ogrenir", "mezun_olunca"]) {
|
||||
const maddeler = liste(alan);
|
||||
if (maddeler.length === 0) uyari(alan, "boş (kaynak bulunamadı) — sahne bu alanı çizmez");
|
||||
else if (maddeler.length !== 3) hata(alan, `tam 3 madde gerekli, ${maddeler.length} var`);
|
||||
maddeler.forEach((m, i) => {
|
||||
const t = (m.metin ?? "").trim();
|
||||
if (!t) hata(alan, `madde ${i + 1}: "metin" boş`);
|
||||
else if (kelimeSayisi(t) > 8) hata(alan, `madde ${i + 1} ${kelimeSayisi(t)} kelime (en çok 8): "${t}"`);
|
||||
const kaynak = Number(m.kaynak);
|
||||
if (!Number.isInteger(kaynak)) hata(alan, `madde ${i + 1}: "kaynak" numarası yok`);
|
||||
else if (!kaynakNolar.has(kaynak)) hata(alan, `madde ${i + 1}: kaynak ${kaynak} tanımlı değil`);
|
||||
for (const y of yasakSozcukler(t)) hata("yasak-sozcuk", `${alan} madde ${i + 1}: "${y}"`);
|
||||
});
|
||||
}
|
||||
|
||||
// Hiçbir maddenin atıf yapmadığı kaynak (yalnız uyarı: destek/teyit kaynağı olabilir)
|
||||
const atifli = new Set<number>();
|
||||
for (const alan of ["ne_ogrenir", "mezun_olunca"]) for (const m of liste(alan)) atifli.add(Number(m.kaynak));
|
||||
for (const no of kaynakNolar) if (!atifli.has(no)) uyari("kaynak", `kaynak ${no} hiçbir maddede kullanılmıyor`);
|
||||
|
||||
// guncelleme
|
||||
if (!TARIH.test(metin("guncelleme"))) hata("guncelleme", "guncelleme YYYY-AA-GG biçiminde olmalı");
|
||||
|
||||
// yasak sözcük: ozet + gövde; gövde ≤ 60 kelime
|
||||
for (const y of yasakSozcukler(ozet)) hata("yasak-sozcuk", `ozet: "${y}"`);
|
||||
for (const y of yasakSozcukler(govde)) hata("yasak-sozcuk", `gövde: "${y}"`);
|
||||
const govdeKelime = kelimeSayisi(govde);
|
||||
if (govdeKelime > 60) hata("govde", `gövde ${govdeKelime} kelime (en çok 60)`);
|
||||
}
|
||||
|
||||
const dosyalar = existsSync(DIZIN)
|
||||
? readdirSync(DIZIN).filter((d) => d.endsWith(".md")).map((d) => join(DIZIN, d)).sort()
|
||||
: [];
|
||||
for (const yol of dosyalar) dosyaDenetle(yol);
|
||||
|
||||
bulgular.sort((a, b) =>
|
||||
a.seviye !== b.seviye ? (a.seviye === "hata" ? -1 : 1) : a.dosya.localeCompare(b.dosya),
|
||||
);
|
||||
for (const b of bulgular) {
|
||||
const etiket = b.seviye === "hata" ? "HATA " : "uyarı";
|
||||
console.log(`${b.dosya} [${etiket}] ${b.kural} — ${b.mesaj}`);
|
||||
}
|
||||
const hata = bulgular.filter((b) => b.seviye === "hata").length;
|
||||
console.log(
|
||||
`\nBölüm içeriği denetimi: ${dosyalar.length} dosya, ${hata} hata, ${bulgular.length - hata} uyarı (docs/spec/S-009 §3.2–3.4)`,
|
||||
);
|
||||
process.exit(hata > 0 ? 1 : 0);
|
||||
59
scripts/bolum-video/kuyruk.ts
Normal file
59
scripts/bolum-video/kuyruk.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Bölüm tanıtım videosu üretim kuyruğu — docs/spec/S-011 §4.
|
||||
* Kullanım: pnpm exec tsx --conditions=react-server scripts/bolum-video/kuyruk.ts [çıktı yolu]
|
||||
* Varsayılan çıktı: ../kolaytercih-post/icerikler/bolum/_kuyruk.json (klasör yoksa açılır).
|
||||
*
|
||||
* Sıra: programSayisi (lisans + önlisans program sayısı) azalan — "durmadan,
|
||||
* popülerlik sırasıyla" (Bilal, 17 Eki 2026). İçeriği hazır üç bölüm
|
||||
* (content/bolum/ altında) listenin başına alınır.
|
||||
*
|
||||
* `tsx --conditions=react-server`: src/lib/katalog.ts "server-only" taşır;
|
||||
* react-server koşulunda o paket boş modüle çözülür (bolum-icerik-denetim.ts ile aynı).
|
||||
* DB salt okunur (src/lib/db.ts readonly açar).
|
||||
*/
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { getAllBolumler } from "../../src/lib/katalog";
|
||||
|
||||
/** İçeriği hazır bölümler (content/bolum/<slug>.md) — kuyruğun başı. */
|
||||
const HAZIR = ["anestezi", "bilgisayar-muhendisligi", "hemsirelik"];
|
||||
|
||||
const cikti = resolve(
|
||||
process.cwd(),
|
||||
process.argv[2] ?? "../kolaytercih-post/icerikler/bolum/_kuyruk.json",
|
||||
);
|
||||
|
||||
const hepsi = getAllBolumler().map((b) => ({
|
||||
slug: b.slug,
|
||||
ad: b.ad,
|
||||
programSayisi: b.programSayisi,
|
||||
lisans: b.lisans,
|
||||
onlisans: b.onlisans,
|
||||
}));
|
||||
|
||||
const hazir = HAZIR.map((s) => hepsi.find((b) => b.slug === s)).filter(
|
||||
(b): b is NonNullable<typeof b> => b != null,
|
||||
);
|
||||
const eksik = HAZIR.filter((s) => !hepsi.some((b) => b.slug === s));
|
||||
if (eksik.length) console.error(`uyarı: katalogda yok, başa alınamadı: ${eksik.join(", ")}`);
|
||||
|
||||
const kalan = hepsi
|
||||
.filter((b) => !HAZIR.includes(b.slug))
|
||||
.sort((a, b) => b.programSayisi - a.programSayisi || a.ad.localeCompare(b.ad, "tr-TR"));
|
||||
|
||||
const sira = [...hazir, ...kalan];
|
||||
const kuyruk = {
|
||||
uretim: new Date().toISOString(),
|
||||
toplam: sira.length,
|
||||
sira,
|
||||
};
|
||||
|
||||
mkdirSync(dirname(cikti), { recursive: true });
|
||||
writeFileSync(cikti, JSON.stringify(kuyruk, null, 2) + "\n", "utf8");
|
||||
console.log(`kuyruk: ${sira.length} bölüm → ${cikti}`);
|
||||
console.log(
|
||||
`ilk 5: ${sira
|
||||
.slice(0, 5)
|
||||
.map((b) => `${b.slug} (${b.programSayisi})`)
|
||||
.join(", ")}`,
|
||||
);
|
||||
93
scripts/bolum-video/sayilar.ts
Normal file
93
scripts/bolum-video/sayilar.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Bölüm tanıtım videosunun sayı dosyası — docs/spec/S-011 §4; sözleşme
|
||||
* kolaytercih-post/icerikler/bolum/_sablon/kurgu.ts `Sayilar` tipi.
|
||||
* Kullanım: pnpm exec tsx --conditions=react-server scripts/bolum-video/sayilar.ts <slug> <lisans|onlisans>
|
||||
* Çıktı: stdout'a JSON (RUNBOOK bunu icerikler/bolum/<slug>/sayilar.json'a yönlendirir).
|
||||
*
|
||||
* Ekrandaki her sayı buradan gelir; kurgu yazan model bu değerleri değiştiremez.
|
||||
* Kaynaklar: yokatlas.db (süre, puan türü, üniversite, il) ve TÜİK istihdam
|
||||
* (src/lib/bolum-istihdam.ts). DB salt okunur.
|
||||
*/
|
||||
import { getBolumBySlug } from "../../src/lib/katalog";
|
||||
import {
|
||||
BOLUM_ISTIHDAM_KAYNAK,
|
||||
BOLUM_ISTIHDAM_KAYNAK_URL,
|
||||
BOLUM_ISTIHDAM_YIL,
|
||||
ISTIHDAM_ORTALAMA,
|
||||
bolumIstihdamBul,
|
||||
type IstihdamDuzeyi,
|
||||
} from "../../src/lib/bolum-istihdam";
|
||||
import { SON_YIL } from "../../src/lib/veri-yillari";
|
||||
|
||||
const YURT_DISI = new Set(["BAKÜ-AZERBAYCAN", "BİŞKEK-KIRGIZİSTAN", "GAZİMAĞUSA", "GÜZELYURT", "GİRNE", "KIBRIS", "LEFKE", "LEFKOŞA", "SARAYBOSNA - BOSNA - HERSEK", "TÜRKİSTAN-KAZAKİSTAN", "ÜSKÜP-MAKEDONYA"]);
|
||||
|
||||
const [slug, duzeyHam] = process.argv.slice(2);
|
||||
if (!slug || (duzeyHam !== "lisans" && duzeyHam !== "onlisans")) {
|
||||
console.error("kullanım: sayilar.ts <slug> <lisans|onlisans>");
|
||||
process.exit(2);
|
||||
}
|
||||
const duzey = duzeyHam as IstihdamDuzeyi;
|
||||
|
||||
const bolum = getBolumBySlug(slug);
|
||||
if (!bolum) {
|
||||
console.error(`katalogda böyle bölüm yok: ${slug}`);
|
||||
process.exit(1);
|
||||
}
|
||||
const programlar = duzey === "lisans" ? bolum.lisansProgramlari : bolum.onlisansProgramlari;
|
||||
if (programlar.length === 0) {
|
||||
console.error(`${slug}: ${duzey} düzeyinde program yok (lisans ${bolum.lisansProgramlari.length}, önlisans ${bolum.onlisansProgramlari.length})`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
/** Süre: o düzeydeki programların modu (2–6 yıl); eşitlikte küçük olan. */
|
||||
function sureModu(): number {
|
||||
const sayim = new Map<number, number>();
|
||||
for (const p of programlar)
|
||||
if (p.sure != null && p.sure >= 2 && p.sure <= 6) sayim.set(p.sure, (sayim.get(p.sure) ?? 0) + 1);
|
||||
let yil: number | null = null;
|
||||
for (const [s, n] of sayim)
|
||||
if (yil == null || n > (sayim.get(yil) ?? 0) || (n === sayim.get(yil) && s < yil)) yil = s;
|
||||
if (yil == null) {
|
||||
yil = duzey === "lisans" ? 4 : 2;
|
||||
console.error(`uyarı: ${slug} ${duzey} için süre verisi yok, varsayılan ${yil} yıl yazıldı`);
|
||||
}
|
||||
return yil;
|
||||
}
|
||||
|
||||
const tuik = bolumIstihdamBul(slug, duzey);
|
||||
const ort = ISTIHDAM_ORTALAMA[duzey];
|
||||
const istihdam =
|
||||
tuik && tuik.istihdam != null && tuik.isBulmaAy != null
|
||||
? {
|
||||
oran: tuik.istihdam,
|
||||
isBulmaAy: tuik.isBulmaAy,
|
||||
yil: BOLUM_ISTIHDAM_YIL,
|
||||
kaynak: BOLUM_ISTIHDAM_KAYNAK,
|
||||
url: BOLUM_ISTIHDAM_KAYNAK_URL,
|
||||
ortalama:
|
||||
ort.istihdam != null && ort.isBulmaAy != null
|
||||
? { oran: ort.istihdam, isBulmaAy: ort.isBulmaAy }
|
||||
: undefined,
|
||||
}
|
||||
: null;
|
||||
if (tuik && !istihdam) console.error(`not: ${slug} ${duzey} TÜİK kaydı eksik alanlı (oran/süre), istihdam null yazıldı`);
|
||||
|
||||
const sayilar = {
|
||||
slug,
|
||||
ad: bolum.ad,
|
||||
duzey,
|
||||
yil: SON_YIL,
|
||||
sure: { yil: sureModu() },
|
||||
puanTurleri: [...new Set(programlar.map((p) => p.tur))].sort((a, b) => a.localeCompare(b, "tr-TR")),
|
||||
programSayisi: programlar.length,
|
||||
universiteSayisi: new Set(programlar.map((p) => p.universite)).size,
|
||||
// Yalnız Türkiye'nin 81 ili: KKTC şehirleri ve yurt dışı kampüsler (BAKÜ-AZERBAYCAN vb.) il sayılmaz
|
||||
ilSayisi: new Set(programlar.map((p) => p.il).filter((il): il is string => !!il && !YURT_DISI.has(il))).size,
|
||||
istihdam,
|
||||
kaynak: {
|
||||
yokatlas: `YÖK Atlas ${SON_YIL}`,
|
||||
sure: `ÖSYM Yükseköğretim Programları ve Kontenjanları Kılavuzu ${SON_YIL}`,
|
||||
},
|
||||
};
|
||||
|
||||
process.stdout.write(JSON.stringify(sayilar, null, 2) + "\n");
|
||||
Reference in New Issue
Block a user