AI Resource Pro / website / scripts / create_gemini_tutorial_content.mjs
| 1 | import fs from 'fs'; |
| 2 | import path from 'path'; |
| 3 | import dotenv from 'dotenv'; |
| 4 | import { createClient } from '@supabase/supabase-js'; |
| 5 | |
| 6 | dotenv.config({ path: '/path/to/file' }); |
| 7 | |
| 8 | const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; |
| 9 | const serviceKey = process.env.SUPABASE_SERVICE_ROLE_KEY; |
| 10 | if (!supabaseUrl || !serviceKey) throw new Error('Missing Supabase credentials'); |
| 11 | |
| 12 | const supabase = createClient(supabaseUrl, serviceKey, { |
| 13 | auth: { autoRefreshToken: false, persistSession: false }, |
| 14 | }); |
| 15 | |
| 16 | const slug = 'google-gemini'; |
| 17 | const heroVideoUrl = 'https://www.youtube.com/watch?v=Uy6LcpyGj7w'; |
| 18 | const verifiedDate = '2026-02-18'; |
| 19 | |
| 20 | const sourceLinks = { |
| 21 | geminiWeb: 'https://gemini.google.com/', |
| 22 | subscriptions: 'https://gemini.google/us/subscriptions/', |
| 23 | oneAiPlans: 'https://one.google.com/about/ai-premium/', |
| 24 | blogFeatureUpdate: 'https://blog.google/products/gemini/new-gemini-app-features-march-2025/', |
| 25 | }; |
| 26 | |
| 27 | const overview = { |
| 28 | hero_headline: 'Use Google Gemini to research, draft, and refine work in 20 minutes', |
| 29 | hero_subhead: 'Start with one goal, add context, and iterate with short prompts to get usable output fast.', |
| 30 | hero_time_estimate_minutes: 20, |
| 31 | quick_verdict: { |
| 32 | best_for: 'Fast drafting, summarizing, and planning with Google account access', |
| 33 | not_for: 'Tasks that need guaranteed citations without manual verification', |
| 34 | setup_time: '5 minutes', |
| 35 | cost_to_start: 'Free', |
| 36 | alternatives: ['ChatGPT', 'Claude'], |
| 37 | }, |
| 38 | metadata: { |
| 39 | verified_on: verifiedDate, |
| 40 | sources: Object.values(sourceLinks), |
| 41 | }, |
| 42 | }; |
| 43 | |
| 44 | const steps = [ |
| 45 | { |
| 46 | step_order: 1, |
| 47 | title: 'Open Gemini and sign in', |
| 48 | objective: 'Get to the chat interface and confirm you are on the correct account.', |
| 49 | instructions_md: 'Go to gemini.google.com, sign in, and start a new chat.', |
| 50 | copy_paste_input: null, |
| 51 | expected_output: 'You see the Gemini chat box and model selector.', |
| 52 | common_error: 'You are redirected or blocked by a workspace policy.', |
| 53 | fix_text: 'Use a personal Google account or ask your admin to allow Gemini access.', |
| 54 | setup_time_minutes: 2, |
| 55 | }, |
| 56 | { |
| 57 | step_order: 2, |
| 58 | title: 'State one clear outcome', |
| 59 | objective: 'Anchor the session to a specific deliverable.', |
| 60 | instructions_md: 'Ask for one output with format, length, and audience.', |
| 61 | copy_paste_input: 'You are my assistant. Create a 150-word summary for a non-technical manager about: [topic]. Include 3 bullet takeaways and one risk.', |
| 62 | expected_output: 'A short summary in the requested structure.', |
| 63 | common_error: 'The reply is too broad or generic.', |
| 64 | fix_text: 'Add audience, length, and required sections in the same prompt.', |
| 65 | setup_time_minutes: 3, |
| 66 | }, |
| 67 | { |
| 68 | step_order: 3, |
| 69 | title: 'Add constraints and source expectations', |
| 70 | objective: 'Reduce guesswork and make the response usable.', |
| 71 | instructions_md: 'Set what to avoid and what evidence you want.', |
| 72 | copy_paste_input: 'Revise this with plain language. Avoid jargon. If you make factual claims, list sources as links at the end.', |
| 73 | expected_output: 'Cleaner draft with explicit source section.', |
| 74 | common_error: 'No sources are listed.', |
| 75 | fix_text: 'Ask again: "List only sources you actually used, as clickable URLs."', |
| 76 | setup_time_minutes: 3, |
| 77 | }, |
| 78 | { |
| 79 | step_order: 4, |
| 80 | title: 'Upload a file for context', |
| 81 | objective: 'Use your own material instead of starting from scratch.', |
| 82 | instructions_md: 'Upload a PDF or doc and request a task tied to that file.', |
| 83 | copy_paste_input: 'Read the uploaded file. Give me: 1) key points, 2) missing assumptions, 3) 5 follow-up questions for stakeholders.', |
| 84 | expected_output: 'File-specific analysis with clear sections.', |
| 85 | common_error: 'Gemini gives a shallow summary.', |
| 86 | fix_text: 'Ask for line-item outputs and a fixed count per section.', |
| 87 | setup_time_minutes: 4, |
| 88 | }, |
| 89 | { |
| 90 | step_order: 5, |
| 91 | title: 'Run one improvement pass', |
| 92 | objective: 'Turn draft output into a final version.', |
| 93 | instructions_md: 'Request a rewrite with strict tone and structure.', |
| 94 | copy_paste_input: 'Rewrite the draft for an executive update. Keep it under 120 words. Use short sentences. End with one decision request.', |
| 95 | expected_output: 'A concise final draft for your audience.', |
| 96 | common_error: 'The rewrite drops important details.', |
| 97 | fix_text: 'Tell Gemini which details are non-negotiable before rewriting.', |
| 98 | setup_time_minutes: 3, |
| 99 | }, |
| 100 | { |
| 101 | step_order: 6, |
| 102 | title: 'Check facts before you publish', |
| 103 | objective: 'Catch incorrect or outdated claims.', |
| 104 | instructions_md: 'Verify claims against first-party sources before external use.', |
| 105 | copy_paste_input: 'List every factual claim in your last answer as a checklist. For each claim, add a source URL or mark it "needs verification."', |
| 106 | expected_output: 'A claim-by-claim verification checklist.', |
| 107 | common_error: 'Some claims still lack sources.', |
| 108 | fix_text: 'Remove or rewrite unsupported claims before using the output.', |
| 109 | setup_time_minutes: 3, |
| 110 | }, |
| 111 | { |
| 112 | step_order: 7, |
| 113 | title: 'Save your prompt pattern', |
| 114 | objective: 'Reuse what worked in future tasks.', |
| 115 | instructions_md: 'Save your best prompt format in notes as a template with placeholders.', |
| 116 | copy_paste_input: 'Template: Goal=[goal]. Audience=[audience]. Output format=[format]. Must include=[items]. Must avoid=[items].', |
| 117 | expected_output: 'A reusable prompt template.', |
| 118 | common_error: 'Template is too vague to reuse.', |
| 119 | fix_text: 'Keep required sections and placeholders explicit.', |
| 120 | setup_time_minutes: 2, |
| 121 | }, |
| 122 | ]; |
| 123 | |
| 124 | const recipes = [ |
| 125 | { |
| 126 | recipe_order: 1, |
| 127 | name: 'Write a product description from raw notes', |
| 128 | audience: 'Marketers and founders', |
| 129 | summary: 'Turn bullet notes into a polished listing fast.', |
| 130 | inputs_required: ['Product name', 'Target buyer', 'Top 3 benefits', 'Tone'], |
| 131 | template_text: 'Create a product description for [product]. Target buyer: [buyer]. Benefits: [benefit 1], [benefit 2], [benefit 3]. Tone: [tone]. Output: 120 words plus 5 bullet highlights.', |
| 132 | output_example: 'A short description plus bullet highlights ready for a product page.', |
| 133 | time_saved_text: 'Saves 20-30 minutes per draft.', |
| 134 | }, |
| 135 | { |
| 136 | recipe_order: 2, |
| 137 | name: 'Analyze a long report into an action plan', |
| 138 | audience: 'Ops and project leads', |
| 139 | summary: 'Extract decisions, risks, and next steps from a dense file.', |
| 140 | inputs_required: ['Uploaded report', 'Project goal', 'Deadline'], |
| 141 | template_text: 'Read the uploaded report. Build a 30-day action plan for [goal] by [deadline]. Return: decisions needed this week, top 5 risks, and owners for each next step.', |
| 142 | output_example: 'A time-bound action plan with owners and risk list.', |
| 143 | time_saved_text: 'Saves 45-60 minutes of manual synthesis.', |
| 144 | }, |
| 145 | { |
| 146 | recipe_order: 3, |
| 147 | name: 'Review a code snippet for bugs and tests', |
| 148 | audience: 'Developers', |
| 149 | summary: 'Get a focused review instead of a generic explanation.', |
| 150 | inputs_required: ['Code snippet', 'Language', 'Expected behavior'], |
| 151 | template_text: 'Review this [language] snippet. Find logical bugs, edge cases, and missing tests. Output format: 1) issue list, 2) fixed code, 3) test cases with expected results. Code: [paste code].', |
| 152 | output_example: 'Prioritized bug list, corrected snippet, and test checklist.', |
| 153 | time_saved_text: 'Saves 15-25 minutes on first-pass review.', |
| 154 | }, |
| 155 | ]; |
| 156 | |
| 157 | const templates = [ |
| 158 | { |
| 159 | template_order: 1, |
| 160 | title: 'Beginner: summarize a topic', |
| 161 | category_tag: 'writing', |
| 162 | tags: ['beginner', 'summary'], |
| 163 | prompt_text: 'Explain [topic] to [audience] in 120 words. Use plain language and 3 bullet takeaways.', |
| 164 | variables: { topic: 'string', audience: 'string' }, |
| 165 | sample_input: 'topic=zero-trust security, audience=small business owner', |
| 166 | sample_output: 'Zero-trust security means every access request is checked each time. It helps reduce damage if one account is compromised. Key takeaways: verify users often, limit access by role, monitor unusual activity.', |
| 167 | difficulty: 'beginner', |
| 168 | }, |
| 169 | { |
| 170 | template_order: 2, |
| 171 | title: 'Beginner: rewrite for clarity', |
| 172 | category_tag: 'writing', |
| 173 | tags: ['beginner', 'editing'], |
| 174 | prompt_text: 'Rewrite this text for clarity. Keep meaning the same. Limit to [word_count] words. Text: [text]', |
| 175 | variables: { word_count: 'number', text: 'string' }, |
| 176 | sample_input: 'word_count=90, text=We are leveraging cross-functional alignment to optimize synergy...', |
| 177 | sample_output: 'We are aligning teams to remove delays and improve delivery speed. The plan sets clear owners and weekly checkpoints.', |
| 178 | difficulty: 'beginner', |
| 179 | }, |
| 180 | { |
| 181 | template_order: 3, |
| 182 | title: 'Intermediate: compare options', |
| 183 | category_tag: 'analysis', |
| 184 | tags: ['intermediate', 'decision-making'], |
| 185 | prompt_text: 'Compare [option_a] vs [option_b] for [use_case]. Return a table with cost, speed, risk, and maintenance.', |
| 186 | variables: { option_a: 'string', option_b: 'string', use_case: 'string' }, |
| 187 | sample_input: 'option_a=managed Postgres, option_b=self-hosted Postgres, use_case=SaaS app', |
| 188 | sample_output: 'Table with tradeoffs: managed is faster to operate, self-hosted gives deeper control but higher ops load.', |
| 189 | difficulty: 'intermediate', |
| 190 | }, |
| 191 | { |
| 192 | template_order: 4, |
| 193 | title: 'Intermediate: meeting brief', |
| 194 | category_tag: 'productivity', |
| 195 | tags: ['intermediate', 'meetings'], |
| 196 | prompt_text: 'Create a meeting brief from these notes: [notes]. Output: agenda, decisions needed, and 5 questions to unblock progress.', |
| 197 | variables: { notes: 'string' }, |
| 198 | sample_input: 'notes=Q2 launch risks include delayed legal review and unclear owner for analytics.', |
| 199 | sample_output: 'Agenda includes legal timeline, analytics ownership decision, and launch checklist review.', |
| 200 | difficulty: 'intermediate', |
| 201 | }, |
| 202 | { |
| 203 | template_order: 5, |
| 204 | title: 'Intermediate: customer email response', |
| 205 | category_tag: 'support', |
| 206 | tags: ['intermediate', 'email'], |
| 207 | prompt_text: 'Draft a customer email reply. Situation: [issue]. Tone: calm and direct. Include apology, fix, and next step.', |
| 208 | variables: { issue: 'string' }, |
| 209 | sample_input: 'issue=invoice charged twice', |
| 210 | sample_output: 'Thanks for flagging this. You were charged twice, and we have issued a refund today. You will see it in 3-5 business days.', |
| 211 | difficulty: 'intermediate', |
| 212 | }, |
| 213 | { |
| 214 | template_order: 6, |
| 215 | title: 'Advanced: SQL query review', |
| 216 | category_tag: 'coding', |
| 217 | tags: ['advanced', 'sql'], |
| 218 | prompt_text: 'Review this SQL query for correctness and performance. Provide: issues, optimized query, and index suggestions. Query: [sql]', |
| 219 | variables: { sql: 'string' }, |
| 220 | sample_input: 'sql=SELECT * FROM orders WHERE DATE(created_at)=CURRENT_DATE;', |
| 221 | sample_output: 'Issue: function on indexed column can block index use. Suggest range filter and index on created_at.', |
| 222 | difficulty: 'advanced', |
| 223 | }, |
| 224 | { |
| 225 | template_order: 7, |
| 226 | title: 'Advanced: PR review checklist', |
| 227 | category_tag: 'coding', |
| 228 | tags: ['advanced', 'code-review'], |
| 229 | prompt_text: 'Create a pull request review checklist for this diff summary: [summary]. Focus on regressions, security, and missing tests.', |
| 230 | variables: { summary: 'string' }, |
| 231 | sample_input: 'summary=adds OAuth callback handler and token refresh logic', |
| 232 | sample_output: 'Checklist includes token validation, CSRF checks, error handling paths, and integration tests for refresh failures.', |
| 233 | difficulty: 'advanced', |
| 234 | }, |
| 235 | { |
| 236 | template_order: 8, |
| 237 | title: 'Advanced: root cause analysis', |
| 238 | category_tag: 'analysis', |
| 239 | tags: ['advanced', 'incident-response'], |
| 240 | prompt_text: 'Given this incident timeline [timeline], produce probable root causes, evidence needed, and a 24-hour remediation plan.', |
| 241 | variables: { timeline: 'string' }, |
| 242 | sample_input: 'timeline=09:10 error spike, 09:14 deploy complete, 09:20 DB saturation', |
| 243 | sample_output: 'Likely causes include deployment query change and connection pool limit; remediation plan prioritizes rollback and query fix.', |
| 244 | difficulty: 'advanced', |
| 245 | }, |
| 246 | { |
| 247 | template_order: 9, |
| 248 | title: 'Beginner: study plan builder', |
| 249 | category_tag: 'learning', |
| 250 | tags: ['beginner', 'planning'], |
| 251 | prompt_text: 'Build a 2-week study plan for [topic] at [minutes_per_day] minutes per day. Include daily tasks and one checkpoint quiz each week.', |
| 252 | variables: { topic: 'string', minutes_per_day: 'number' }, |
| 253 | sample_input: 'topic=Python basics, minutes_per_day=30', |
| 254 | sample_output: 'Day-by-day plan covering syntax, functions, loops, and mini exercises with weekly quizzes.', |
| 255 | difficulty: 'beginner', |
| 256 | }, |
| 257 | { |
| 258 | template_order: 10, |
| 259 | title: 'Intermediate: convert notes to task list', |
| 260 | category_tag: 'productivity', |
| 261 | tags: ['intermediate', 'task-management'], |
| 262 | prompt_text: 'Convert these notes into an actionable task list. For each task include owner, due date, and dependency. Notes: [notes]', |
| 263 | variables: { notes: 'string' }, |
| 264 | sample_input: 'notes=Finalize pricing page copy, legal sign-off pending, design handoff Friday', |
| 265 | sample_output: 'Task list with owners for copy, legal review dependency, and design handoff milestone.', |
| 266 | difficulty: 'intermediate', |
| 267 | }, |
| 268 | ]; |
| 269 | |
| 270 | const comparisons = [ |
| 271 | { |
| 272 | comparison_order: 1, |
| 273 | alternative_name: 'ChatGPT', |
| 274 | alternative_url: 'https://chatgpt.com/', |
| 275 | when_to_choose_this: 'Choose Gemini when you want tight integration with Google services and one account across Google apps.', |
| 276 | when_to_choose_alternative: 'Choose ChatGPT when your team already uses OpenAI workflows or custom GPT-based processes.', |
| 277 | comparison_matrix: { |
| 278 | best_at: { |
| 279 | gemini: 'Google ecosystem tasks and fast drafting', |
| 280 | alternative: 'Broad third-party ecosystem and custom GPT workflows', |
| 281 | }, |
| 282 | note: 'Both are strong for writing, analysis, and coding prompts.', |
| 283 | }, |
| 284 | }, |
| 285 | { |
| 286 | comparison_order: 2, |
| 287 | alternative_name: 'Claude', |
| 288 | alternative_url: 'https://claude.ai/', |
| 289 | when_to_choose_this: 'Choose Gemini for users already working inside Google accounts and services.', |
| 290 | when_to_choose_alternative: 'Choose Claude when you prefer its writing style or internal policy standards for long-form drafts.', |
| 291 | comparison_matrix: { |
| 292 | best_at: { |
| 293 | gemini: 'Everyday productivity tied to Google tools', |
| 294 | alternative: 'Long-form drafting and policy-heavy writing workflows', |
| 295 | }, |
| 296 | note: 'Test both on your real prompts before standardizing.', |
| 297 | }, |
| 298 | }, |
| 299 | { |
| 300 | comparison_order: 3, |
| 301 | alternative_name: 'Perplexity', |
| 302 | alternative_url: 'https://www.perplexity.ai/', |
| 303 | when_to_choose_this: 'Choose Gemini for iterative drafting and planning inside a chat workflow.', |
| 304 | when_to_choose_alternative: 'Choose Perplexity when you need citation-first web answers as the default output.', |
| 305 | comparison_matrix: { |
| 306 | best_at: { |
| 307 | gemini: 'Drafting and refinement passes', |
| 308 | alternative: 'Research with visible source citations', |
| 309 | }, |
| 310 | note: 'Use Gemini plus manual source checks for high-stakes facts.', |
| 311 | }, |
| 312 | }, |
| 313 | ]; |
| 314 | |
| 315 | const faqs = [ |
| 316 | { |
| 317 | faq_order: 1, |
| 318 | question: 'Is Google Gemini free to use?', |
| 319 | answer_md: 'Yes. Gemini has a free tier. Paid plans exist for higher limits and extra features. Check current options on the Gemini subscriptions page because plans vary by region.', |
| 320 | error_signature: null, |
| 321 | quick_fix: 'If you only need basic chat and drafting, start on the free tier first.', |
| 322 | }, |
| 323 | { |
| 324 | faq_order: 2, |
| 325 | question: 'How long does setup take for a new user?', |
| 326 | answer_md: 'Most users can start in about 5 minutes: sign in, open a new chat, and send the first prompt.', |
| 327 | error_signature: null, |
| 328 | quick_fix: 'Use a personal Google account if your workspace account blocks access.', |
| 329 | }, |
| 330 | { |
| 331 | faq_order: 3, |
| 332 | question: 'Why are my Gemini outputs too generic?', |
| 333 | answer_md: 'Prompts that lack audience, format, and constraints usually produce generic text.', |
| 334 | error_signature: 'Output is broad and non-specific', |
| 335 | quick_fix: 'Add audience, exact format, length limit, and required sections in one prompt.', |
| 336 | }, |
| 337 | { |
| 338 | faq_order: 4, |
| 339 | question: 'Can Gemini read uploaded files?', |
| 340 | answer_md: 'Yes, file upload support is available in Gemini app experiences. Ask for structured outputs tied to the uploaded file for better results.', |
| 341 | error_signature: 'File summarized with low detail', |
| 342 | quick_fix: 'Request fixed sections, counts, and follow-up questions instead of a single generic summary.', |
| 343 | }, |
| 344 | { |
| 345 | faq_order: 5, |
| 346 | question: 'How do I reduce factual errors?', |
| 347 | answer_md: 'Treat model output as a draft. Ask Gemini to list factual claims and source links, then verify each claim on first-party sources before use.', |
| 348 | error_signature: 'Unverified claims in output', |
| 349 | quick_fix: 'Remove claims without sources or rewrite them as assumptions.', |
| 350 | }, |
| 351 | { |
| 352 | faq_order: 6, |
| 353 | question: 'Why can’t I access some Gemini features?', |
| 354 | answer_md: 'Feature availability depends on plan, region, account type, and rollout timing.', |
| 355 | error_signature: 'Feature missing from UI', |
| 356 | quick_fix: 'Check account type, region support, and current plan details on official Gemini plan pages.', |
| 357 | }, |
| 358 | { |
| 359 | faq_order: 7, |
| 360 | question: 'Should I use one long prompt or several short prompts?', |
| 361 | answer_md: 'Short iterative prompts usually work better. Start with the goal, then run one refinement pass per issue.', |
| 362 | error_signature: null, |
| 363 | quick_fix: 'Split work into draft, critique, and rewrite steps.', |
| 364 | }, |
| 365 | { |
| 366 | faq_order: 8, |
| 367 | question: 'Can Gemini help with coding tasks?', |
| 368 | answer_md: 'Yes. It can explain code, suggest fixes, and draft tests. Always run and review code locally before merging.', |
| 369 | error_signature: 'Code compiles but behavior is wrong', |
| 370 | quick_fix: 'Ask for edge cases and test cases, then validate with your project test suite.', |
| 371 | }, |
| 372 | { |
| 373 | faq_order: 9, |
| 374 | question: 'What is the fastest way to improve prompt quality?', |
| 375 | answer_md: 'Use a template with fixed fields: goal, audience, format, must-include items, and must-avoid items.', |
| 376 | error_signature: null, |
| 377 | quick_fix: 'Save your top prompt format and reuse it instead of writing from scratch each time.', |
| 378 | }, |
| 379 | ]; |
| 380 | |
| 381 | async function must(promise, label) { |
| 382 | const { data, error, count } = await promise; |
| 383 | if (error) throw new Error(`${label}: ${error.message}`); |
| 384 | return { data, count }; |
| 385 | } |
| 386 | |
| 387 | const report = { |
| 388 | created_at: new Date().toISOString(), |
| 389 | slug, |
| 390 | selected_video: { |
| 391 | url: heroVideoUrl, |
| 392 | title: 'Master 85% of Google Gemini in 12 Minutes', |
| 393 | channel: 'Jeff Su', |
| 394 | upload_date: '2025-05-06', |
| 395 | views_at_research_time: 718433, |
| 396 | reason: 'Highest view count among beginner-oriented Gemini tutorials published within the last year during research.', |
| 397 | research_method: 'yt-dlp metadata pull on 2026-02-18', |
| 398 | }, |
| 399 | sources_used: sourceLinks, |
| 400 | }; |
| 401 | |
| 402 | async function run() { |
| 403 | const toolRes = await must( |
| 404 | supabase.from('tools').select('id,name,slug').eq('slug', slug).maybeSingle(), |
| 405 | 'find tool by slug' |
| 406 | ); |
| 407 | const tool = toolRes.data; |
| 408 | if (!tool) throw new Error(`Tool not found for slug=${slug}`); |
| 409 | const toolId = tool.id; |
| 410 | |
| 411 | await must( |
| 412 | supabase |
| 413 | .from('tools') |
| 414 | .update({ |
| 415 | tutorial_enabled: true, |
| 416 | tutorial_hero_video_url: heroVideoUrl, |
| 417 | tutorial_last_reviewed_at: new Date().toISOString(), |
| 418 | tutorial_schema_version: 1, |
| 419 | }) |
| 420 | .eq('id', toolId), |
| 421 | 'update tools row' |
| 422 | ); |
| 423 | |
| 424 | const cleanupTables = [ |
| 425 | 'tool_tutorial_overviews', |
| 426 | 'tool_tutorial_steps', |
| 427 | 'tool_workflow_recipes', |
| 428 | 'tool_prompt_templates', |
| 429 | 'tool_comparisons', |
| 430 | 'tool_tutorial_faqs', |
| 431 | ]; |
| 432 | |
| 433 | for (const table of cleanupTables) { |
| 434 | await must(supabase.from(table).delete().eq('tool_id', toolId), `cleanup ${table}`); |
| 435 | } |
| 436 | |
| 437 | const overviewInsert = await must( |
| 438 | supabase.from('tool_tutorial_overviews').insert({ tool_id: toolId, ...overview }).select('*').single(), |
| 439 | 'insert overview' |
| 440 | ); |
| 441 | |
| 442 | const stepsInsert = await must( |
| 443 | supabase.from('tool_tutorial_steps').insert(steps.map((s) => ({ tool_id: toolId, ...s }))).select('*'), |
| 444 | 'insert steps' |
| 445 | ); |
| 446 | |
| 447 | const recipesInsert = await must( |
| 448 | supabase.from('tool_workflow_recipes').insert(recipes.map((r) => ({ tool_id: toolId, ...r, inputs_required: r.inputs_required }))).select('*'), |
| 449 | 'insert recipes' |
| 450 | ); |
| 451 | |
| 452 | const templatesInsert = await must( |
| 453 | supabase.from('tool_prompt_templates').insert(templates.map((t) => ({ tool_id: toolId, ...t }))).select('*'), |
| 454 | 'insert templates' |
| 455 | ); |
| 456 | |
| 457 | const comparisonsInsert = await must( |
| 458 | supabase.from('tool_comparisons').insert(comparisons.map((c) => ({ tool_id: toolId, ...c }))).select('*'), |
| 459 | 'insert comparisons' |
| 460 | ); |
| 461 | |
| 462 | const faqsInsert = await must( |
| 463 | supabase.from('tool_tutorial_faqs').insert(faqs.map((f) => ({ tool_id: toolId, ...f }))).select('*'), |
| 464 | 'insert faqs' |
| 465 | ); |
| 466 | |
| 467 | const tableCounts = {}; |
| 468 | for (const table of cleanupTables) { |
| 469 | const res = await must(supabase.from(table).select('*', { count: 'exact', head: true }).eq('tool_id', toolId), `count ${table}`); |
| 470 | tableCounts[table] = res.count ?? 0; |
| 471 | } |
| 472 | |
| 473 | report.tool = { id: toolId, name: tool.name, slug: tool.slug }; |
| 474 | report.updated_tools_fields = { |
| 475 | tutorial_enabled: true, |
| 476 | tutorial_hero_video_url: heroVideoUrl, |
| 477 | tutorial_schema_version: 1, |
| 478 | }; |
| 479 | report.created_records = { |
| 480 | tool_tutorial_overviews: overviewInsert.data, |
| 481 | tool_tutorial_steps: stepsInsert.data, |
| 482 | tool_workflow_recipes: recipesInsert.data, |
| 483 | tool_prompt_templates: templatesInsert.data, |
| 484 | tool_comparisons: comparisonsInsert.data, |
| 485 | tool_tutorial_faqs: faqsInsert.data, |
| 486 | }; |
| 487 | report.row_counts_for_tool = tableCounts; |
| 488 | |
| 489 | const lines = []; |
| 490 | lines.push('# Google Gemini Tutorial Content Report'); |
| 491 | lines.push(''); |
| 492 | lines.push(`- Generated at: ${report.created_at}`); |
| 493 | lines.push(`- Tool: ${tool.name} (id=${toolId}, slug=${tool.slug})`); |
| 494 | lines.push(''); |
| 495 | lines.push('## Hero Video Selected'); |
| 496 | lines.push(`- URL: ${report.selected_video.url}`); |
| 497 | lines.push(`- Title: ${report.selected_video.title}`); |
| 498 | lines.push(`- Channel: ${report.selected_video.channel}`); |
| 499 | lines.push(`- Upload date: ${report.selected_video.upload_date}`); |
| 500 | lines.push(`- Views at research time: ${report.selected_video.views_at_research_time}`); |
| 501 | lines.push(`- Selection reason: ${report.selected_video.reason}`); |
| 502 | lines.push(''); |
| 503 | lines.push('## Tools Row Update'); |
| 504 | lines.push(`- tutorial_enabled: true`); |
| 505 | lines.push(`- tutorial_hero_video_url: ${heroVideoUrl}`); |
| 506 | lines.push(`- tutorial_schema_version: 1`); |
| 507 | lines.push(''); |
| 508 | lines.push('## Row Counts (for tool_id)'); |
| 509 | for (const [table, count] of Object.entries(tableCounts)) { |
| 510 | lines.push(`- ${table}: ${count}`); |
| 511 | } |
| 512 | lines.push(''); |
| 513 | lines.push('## Created Records (JSON)'); |
| 514 | lines.push('```json'); |
| 515 | lines.push(JSON.stringify(report.created_records, null, 2)); |
| 516 | lines.push('```'); |
| 517 | lines.push(''); |
| 518 | lines.push('## Source Links Used For Verification'); |
| 519 | for (const [key, url] of Object.entries(sourceLinks)) { |
| 520 | lines.push(`- ${key}: ${url}`); |
| 521 | } |
| 522 | |
| 523 | fs.writeFileSync('/tmp/gemini-tutorial-report.md', lines.join('\n')); |
| 524 | console.log(JSON.stringify({ success: true, tool_id: toolId, row_counts_for_tool: tableCounts }, null, 2)); |
| 525 | } |
| 526 | |
| 527 | run().catch((err) => { |
| 528 | console.error(err.message); |
| 529 | process.exit(1); |
| 530 | }); |