This commit is contained in:
2026-06-06 15:09:46 -04:00
parent 78220d3568
commit 06295c83ca
56 changed files with 12018 additions and 440 deletions

View File

@@ -20,7 +20,7 @@ import { getDb, closeDb } from "../src/lib/db/index";
import { diseases, plants } from "../src/lib/db/schema";
import PLANTS from "./plant-list";
import { GENERIC_TEMPLATES, getTemplatesForFamily, slugify } from "./disease-templates";
import type { Disease, CausalAgentType, Severity } from "../src/lib/types";
import type { CausalAgentType, Prevalence, Severity } from "../src/lib/types";
interface DiseaseEntry {
id: string;
@@ -35,6 +35,7 @@ interface DiseaseEntry {
prevention: string[];
lookalikeIds: string[];
severity: Severity;
prevalence: Prevalence;
sourceUrl: string;
}
@@ -92,7 +93,6 @@ async function main() {
// Determine how many diseases we need for this plant
const targetMin = 15; // minimum diseases per plant
const targetMax = 45; // maximum diseases per plant
// Get family-specific templates
const familyTemplates = getTemplatesForFamily(plant.fam);
@@ -128,6 +128,7 @@ async function main() {
prevention: tmpl.prevention,
lookalikeIds: [],
severity: tmpl.severity,
prevalence: tmpl.severity === "critical" ? "uncommon" : "common",
sourceUrl: "https://pddc.wisc.edu/ (UW-Madison PDDC extension factsheets)",
});
}
@@ -202,7 +203,7 @@ async function main() {
for (let i = 0; i < toInsert.length; i += BATCH) {
const chunk = toInsert.slice(i, i + BATCH);
const stmts = chunk.map((d) => ({
sql: `INSERT OR IGNORE INTO diseases (id, plant_id, name, scientific_name, causal_agent_type, description, symptoms, causes, treatment, prevention, lookalike_ids, severity, source_url) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
sql: `INSERT OR IGNORE INTO diseases (id, plant_id, name, scientific_name, causal_agent_type, description, symptoms, causes, treatment, prevention, lookalike_ids, severity, prevalence, source_url) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
args: [
d.id,
d.plantId,
@@ -216,6 +217,7 @@ async function main() {
JSON.stringify(d.prevention),
JSON.stringify(d.lookalikeIds),
d.severity,
d.prevalence ?? "uncommon",
d.sourceUrl,
],
}));