dwh_spota: nama kelompok keahlian, bukan ID
getListDataTAMahasiswa mengirim kelompokKeahlian berupa idKK (1..4), sehingga dashboard menampilkan "1 2 3 4". Load kini ikut menarik getListKK ke raw.spota_kk dan staging memetakan ID -> nama; daftar cadangan dari tb_kelompok_keahlian SPOTA dipakai bila getListKK gagal atau bentuk responsnya lain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
02a9e6f848
commit
ddf7ed0a17
@@ -85,13 +85,32 @@ def _waktu(v) -> datetime | None:
|
||||
return None
|
||||
|
||||
|
||||
def _kk_rows() -> list:
|
||||
"""(id, nama) kelompok keahlian dari getListKK. Bentuk responsnya tidak terdokumentasi, jadi nama kolom
|
||||
dicari dari beberapa kemungkinan; bila gagal, staging memakai daftar cadangan (lihat dwh_spota_sql.py)."""
|
||||
try:
|
||||
data = _spota_get("getListKK.php")
|
||||
except Exception as exc: # noqa: BLE001 - KK hanya label, jangan gagalkan seluruh load
|
||||
logger.warning("getListKK tidak terbaca, pakai daftar KK cadangan: %s", exc)
|
||||
return []
|
||||
rows = []
|
||||
for k in data:
|
||||
if not isinstance(k, dict):
|
||||
continue
|
||||
id_kk = next((k[c] for c in ("idKK", "id_kk", "id") if c in k), None)
|
||||
nama = next((k[c] for c in ("namaKK", "nama_kk", "nama", "name") if c in k), None)
|
||||
rows.append((_int(id_kk), _teks(nama)))
|
||||
return rows
|
||||
|
||||
|
||||
def _extract() -> list:
|
||||
"""(tabel raw, [(kolom, tipe postgres)], baris) dari 4 endpoint SPOTA."""
|
||||
"""(tabel raw, [(kolom, tipe postgres)], baris) dari 5 endpoint SPOTA."""
|
||||
ta = _spota_get("getListTugasAkhir.php", {"withoutKep": 1})
|
||||
data = _spota_get("getListDataTAMahasiswa.php")
|
||||
mhs = _spota_get("getListMahasiswa.php") # tanpa withHP: nomor HP tidak ikut
|
||||
dosen = _spota_get("getListDosen.php")
|
||||
return [
|
||||
("spota_kk", [("id", "int"), ("nama", "text")], _kk_rows()),
|
||||
(
|
||||
"spota_tugas_akhir",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user