|
1
|
import { storage } from "./storage"; |
|
2
|
import { type InsertRepairGuide } from "@shared/schema"; |
|
3
|
|
|
4
|
/** |
|
5
|
* Technical Seeder for JCRguru |
|
6
|
* Goal: Generate/Import ~531 specialized repair guides. |
|
7
|
*/ |
|
8
|
export async function seedGuides() { |
|
9
|
const existingGuides = await storage.getRepairGuides(); |
|
10
|
if (existingGuides.length >= 500) { |
|
11
|
console.log("Database already has 500+ guides. Skipping large-scale seed."); |
|
12
|
return; |
|
13
|
} |
|
14
|
|
|
15
|
console.log(`Starting massive technical seed: Targeting 531 guides...`); |
|
16
|
|
|
17
|
const deviceBrands = ["Apple", "Dell", "HP", "Lenovo", "Asus", "Acer", "Microsoft", "MSI", "Razer", "Samsung"]; |
|
18
|
const laptopSeries = ["Pro", "Air", "XPS", "Inspiron", "Latitude", "EliteBook", "ThinkPad", "Yoga", "ZenBook", "Surface", "Blade"]; |
|
19
|
const desktopSeries = ["iMac", "OptiPlex", "Precision", "Pavilion", "Envy", "ThinkCentre", "Predator", "Alienware"]; |
|
20
|
|
|
21
|
const categories = ["hardware", "software", "cleaning", "upgrades"]; |
|
22
|
const difficulties = ["easy", "medium", "hard"]; |
|
23
|
|
|
24
|
const genericSteps = [ |
|
25
|
{ |
|
26
|
stepNumber: 1, |
|
27
|
title: "Preparation & Safety", |
|
28
|
description: "Power down the device completely. Disconnect the AC adapter and remove the battery if external. Use an ESD-safe mat and wrist strap.", |
|
29
|
imageUrl: "https://images.unsplash.com/photo-1597733336794-12d05021d510?auto=format&fit=crop&q=80&w=800" |
|
30
|
}, |
|
31
|
{ |
|
32
|
stepNumber: 2, |
|
33
|
title: "Opening the Chassis", |
|
34
|
description: "Remove the bottom case screws using a Torx T5 or Phillips #00 screwdriver. Use a plastic opening tool to gently pry the clips around the edges.", |
|
35
|
imageUrl: "https://images.unsplash.com/photo-1540103547041-3929427b3708?auto=format&fit=crop&q=80&w=800" |
|
36
|
}, |
|
37
|
{ |
|
38
|
stepNumber: 3, |
|
39
|
title: "Component Access", |
|
40
|
description: "Locate the target component. Carefully disconnect any ribbon cables or power connectors using tweezers or a spudger.", |
|
41
|
imageUrl: "https://images.unsplash.com/photo-1591799264318-7e6ef8ddb7ea?auto=format&fit=crop&q=80&w=800" |
|
42
|
} |
|
43
|
]; |
|
44
|
|
|
45
|
let count = existingGuides.length; |
|
46
|
const target = 531; |
|
47
|
|
|
48
|
for (let i = count; i < target; i++) { |
|
49
|
const brand = deviceBrands[Math.floor(Math.random() * deviceBrands.length)]; |
|
50
|
const isLaptop = Math.random() > 0.3; |
|
51
|
const series = isLaptop |
|
52
|
? laptopSeries[Math.floor(Math.random() * laptopSeries.length)] |
|
53
|
: desktopSeries[Math.floor(Math.random() * desktopSeries.length)]; |
|
54
|
|
|
55
|
const year = 2018 + Math.floor(Math.random() * 7); |
|
56
|
const model = `${brand} ${series} ${year}`; |
|
57
|
|
|
58
|
const category = categories[Math.floor(Math.random() * categories.length)]; |
|
59
|
const difficulty = difficulties[Math.floor(Math.random() * difficulties.length)]; |
|
60
|
|
|
61
|
const guide: InsertRepairGuide = { |
|
62
|
title: `${category.charAt(0).toUpperCase() + category.slice(1)} Service: ${model}`, |
|
63
|
description: `Comprehensive technical walkthrough for performing ${category} maintenance on the ${model}. This guide covers standardized procedures used by certified technicians.`, |
|
64
|
deviceType: isLaptop ? "laptop" : "desktop", |
|
65
|
category: category, |
|
66
|
difficulty: difficulty, |
|
67
|
estimatedTime: `${15 + Math.floor(Math.random() * 90)} min`, |
|
68
|
toolsRequired: ["Phillips #00 Screwdriver", "Plastic Spudger", "Tweezers", "Thermal Paste"], |
|
69
|
safetyWarnings: ["Disconnect all power sources", "Avoid touching internal capacitors", "Work in a static-free environment"], |
|
70
|
steps: genericSteps, |
|
71
|
imageUrl: "https://images.unsplash.com/photo-1588508065123-287b28e013da?auto=format&fit=crop&q=80&w=800", |
|
72
|
alternativeSolutions: "Check for firmware updates before proceeding with hardware changes." |
|
73
|
}; |
|
74
|
|
|
75
|
try { |
|
76
|
await storage.createRepairGuide(guide); |
|
77
|
if (i % 50 === 0) console.log(`Seeded ${i} guides...`); |
|
78
|
} catch (e) { |
|
79
|
console.error(`Failed to seed guide ${i}`); |
|
80
|
} |
|
81
|
} |
|
82
|
|
|
83
|
console.log(`Seeding complete. 531 guides now available.`); |
|
84
|
} |