Upload 3 files
Browse files- app.js +49 -0
- data.js +0 -0
- generate-data.mjs +26 -21
app.js
CHANGED
|
@@ -208,6 +208,53 @@ function hydrateRecordKeys(records) {
|
|
| 208 |
});
|
| 209 |
}
|
| 210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
function riyadhToday() {
|
| 212 |
return new Intl.DateTimeFormat("en-CA", {
|
| 213 |
timeZone: "Asia/Riyadh",
|
|
@@ -253,6 +300,7 @@ async function syncResearcherDocumentation() {
|
|
| 253 |
try {
|
| 254 |
const result = await fetchDocumentation("status", sessionAccessCode);
|
| 255 |
documentationRecords = hydrateRecordKeys(result.records || []);
|
|
|
|
| 256 |
} catch (error) {
|
| 257 |
console.warn(error.message);
|
| 258 |
documentationRecords = [];
|
|
@@ -588,6 +636,7 @@ async function loadAdminDashboard({ automatic = false } = {}) {
|
|
| 588 |
try {
|
| 589 |
const result = await fetchDocumentation("admin", sessionAccessCode);
|
| 590 |
const incomingRecords = hydrateRecordKeys(result.records || []);
|
|
|
|
| 591 |
if (adminDashboardInitialized) {
|
| 592 |
const previousIds = new Set(adminRecords.map(adminRecordIdentity));
|
| 593 |
newAdminRecordIds = new Set(
|
|
|
|
| 208 |
});
|
| 209 |
}
|
| 210 |
|
| 211 |
+
function preserveDocumentedRows(records) {
|
| 212 |
+
if (!payload?.rows?.length || !Array.isArray(records) || !records.length) return;
|
| 213 |
+
const existingKeys = new Set(payload.rows.map((row) => row.sampleKey));
|
| 214 |
+
const extraRows = [];
|
| 215 |
+
|
| 216 |
+
records.forEach((record) => {
|
| 217 |
+
if (!record.sampleKey || existingKeys.has(record.sampleKey) || !record.establishmentName) return;
|
| 218 |
+
existingKeys.add(record.sampleKey);
|
| 219 |
+
extraRows.push({
|
| 220 |
+
researcher: record.researcher || "غير محدد",
|
| 221 |
+
establishmentName: record.establishmentName,
|
| 222 |
+
contractNumber: record.contractNumber || "لا يوجد رقم عقد",
|
| 223 |
+
city: record.city || "غير محدد",
|
| 224 |
+
sourceCity: record.city || "غير محدد",
|
| 225 |
+
representativeCity: record.city || "غير محدد",
|
| 226 |
+
status: record.fieldStatus || "توثيق سابق",
|
| 227 |
+
madonStatement: "",
|
| 228 |
+
madonNoteText: "",
|
| 229 |
+
coordinates: "",
|
| 230 |
+
locationType: "none",
|
| 231 |
+
commercialRecord: record.commercialRecord || "",
|
| 232 |
+
unifiedNumber: "",
|
| 233 |
+
activityCode: "",
|
| 234 |
+
activity: "",
|
| 235 |
+
sampleKey: record.sampleKey,
|
| 236 |
+
preservedDocumentation: true,
|
| 237 |
+
});
|
| 238 |
+
});
|
| 239 |
+
|
| 240 |
+
if (!extraRows.length) return;
|
| 241 |
+
payload.rows = [...payload.rows, ...extraRows];
|
| 242 |
+
const counts = new Map();
|
| 243 |
+
payload.rows.forEach((row) => counts.set(row.researcher, (counts.get(row.researcher) || 0) + 1));
|
| 244 |
+
const researchers = new Map(payload.researchers.map((researcher) => [researcher.name, researcher]));
|
| 245 |
+
counts.forEach((count, name) => {
|
| 246 |
+
const existing = researchers.get(name);
|
| 247 |
+
researchers.set(name, {
|
| 248 |
+
name,
|
| 249 |
+
count,
|
| 250 |
+
mapUrl: existing?.mapUrl || "",
|
| 251 |
+
});
|
| 252 |
+
});
|
| 253 |
+
payload.researchers = [...researchers.values()].sort((a, b) =>
|
| 254 |
+
a.name.localeCompare(b.name, "ar", { sensitivity: "base" }),
|
| 255 |
+
);
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
function riyadhToday() {
|
| 259 |
return new Intl.DateTimeFormat("en-CA", {
|
| 260 |
timeZone: "Asia/Riyadh",
|
|
|
|
| 300 |
try {
|
| 301 |
const result = await fetchDocumentation("status", sessionAccessCode);
|
| 302 |
documentationRecords = hydrateRecordKeys(result.records || []);
|
| 303 |
+
preserveDocumentedRows(documentationRecords);
|
| 304 |
} catch (error) {
|
| 305 |
console.warn(error.message);
|
| 306 |
documentationRecords = [];
|
|
|
|
| 636 |
try {
|
| 637 |
const result = await fetchDocumentation("admin", sessionAccessCode);
|
| 638 |
const incomingRecords = hydrateRecordKeys(result.records || []);
|
| 639 |
+
preserveDocumentedRows(incomingRecords);
|
| 640 |
if (adminDashboardInitialized) {
|
| 641 |
const previousIds = new Set(adminRecords.map(adminRecordIdentity));
|
| 642 |
newAdminRecordIds = new Set(
|
data.js
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
generate-data.mjs
CHANGED
|
@@ -5,27 +5,32 @@ import { FileBlob, SpreadsheetFile } from "@oai/artifact-tool";
|
|
| 5 |
const [inputPath, outputPath, password = "20302030", supervisorPassword = "1448"] = process.argv.slice(2);
|
| 6 |
|
| 7 |
const MAP_URLS = [
|
| 8 |
-
["
|
| 9 |
-
["
|
| 10 |
-
["ر
|
| 11 |
-
["
|
| 12 |
-
["
|
| 13 |
-
["
|
| 14 |
-
["
|
| 15 |
-
["
|
| 16 |
-
["ع
|
| 17 |
-
["ع
|
| 18 |
-
["
|
| 19 |
-
["
|
| 20 |
-
["
|
| 21 |
-
["
|
| 22 |
-
["
|
| 23 |
-
["م
|
| 24 |
-
["
|
| 25 |
-
["ن
|
| 26 |
-
["
|
| 27 |
-
["
|
| 28 |
-
["
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
];
|
| 30 |
|
| 31 |
function clean(value) {
|
|
|
|
| 5 |
const [inputPath, outputPath, password = "20302030", supervisorPassword = "1448"] = process.argv.slice(2);
|
| 6 |
|
| 7 |
const MAP_URLS = [
|
| 8 |
+
["صالح عبدالله صالح الدخيل", "https://stat2025-map.static.hf.space/Rahn/01.html"],
|
| 9 |
+
["عبدالرحمن عبدالله سعد الحماد", "https://stat2025-map.static.hf.space/Rahn/02.html"],
|
| 10 |
+
["نوار عوض مقبل العنزى", "https://stat2025-map.static.hf.space/Rahn/03.html"],
|
| 11 |
+
["ناصر منصور علي الرويس", "https://stat2025-map.static.hf.space/Rahn/04.html"],
|
| 12 |
+
["عبدالعزيز فهد عبدالعزيز العبلان", "https://stat2025-map.static.hf.space/Rahn/05.html"],
|
| 13 |
+
["فاطمة حميدي هيف القحطاني", "https://stat2025-map.static.hf.space/Rahn/06.html"],
|
| 14 |
+
["أماني مصطفى عبدالله الطيب", "https://stat2025-map.static.hf.space/Rahn/07.html"],
|
| 15 |
+
["فوز عائد نومان المطيري", "https://stat2025-map.static.hf.space/Rahn/08.html"],
|
| 16 |
+
["ماجد سعد ناصر السبيعي", "https://stat2025-map.static.hf.space/Rahn/09.html"],
|
| 17 |
+
["نوف سعود بن سالم الخثعمي", "https://stat2025-map.static.hf.space/Rahn/10.html"],
|
| 18 |
+
["ريم بنت محمد بن عبدالعزيز الملحم", "https://stat2025-map.static.hf.space/Rahn/11.html"],
|
| 19 |
+
["ساره خالد سليمان المحيسن", "https://stat2025-map.static.hf.space/Rahn/12.html"],
|
| 20 |
+
["هبه عبدالعزيز", "https://stat2025-map.static.hf.space/Rahn/13.html"],
|
| 21 |
+
["نيللي حسين عبدالله الجعص", "https://stat2025-map.static.hf.space/Rahn/14.html"],
|
| 22 |
+
["عماد بن عيسى بن", "https://stat2025-map.static.hf.space/Rahn/15.html"],
|
| 23 |
+
["قنوت محمد بن عبدالله آل حماد", "https://stat2025-map.static.hf.space/Rahn/16.html"],
|
| 24 |
+
["غادة سعد عبدالرحمن الراحله", "https://stat2025-map.static.hf.space/Rahn/17.html"],
|
| 25 |
+
["لين أحمد بن عبدالعزيز القصير", "https://stat2025-map.static.hf.space/Rahn/18.html"],
|
| 26 |
+
["زكي بن عيسى بن", "https://stat2025-map.static.hf.space/Rahn/19.html"],
|
| 27 |
+
["علي جابر بن علي", "https://stat2025-map.static.hf.space/Rahn/20.html"],
|
| 28 |
+
["نبأ عادل بن عبدالكريم", "https://stat2025-map.static.hf.space/Rahn/21.html"],
|
| 29 |
+
["اسعد بن ماجد بن", "https://stat2025-map.static.hf.space/Rahn/22.html"],
|
| 30 |
+
["مرتضى عبدالجليل بن عيسى", "https://stat2025-map.static.hf.space/Rahn/23.html"],
|
| 31 |
+
["ساره حسين بن عبدالهادي بوخمسين", "https://stat2025-map.static.hf.space/Rahn/24.html"],
|
| 32 |
+
["طيبه فالح بن عبدالله الرويشد", "https://stat2025-map.static.hf.space/Rahn/25.html"],
|
| 33 |
+
["فارس سمير سليماني", "https://stat2025-map.static.hf.space/Rahn/26.html"],
|
| 34 |
];
|
| 35 |
|
| 36 |
function clean(value) {
|