Skip to main content
Glama
josuekongolo

CompanyIQ MCP Server

by josuekongolo
DATABASE_FIX.mdβ€’3.07 kB
# βœ… Database Retrieval Fixed **Issue:** "Data gets saved but only retrieves 2024" **Root Cause:** Scraper was saving years WITHOUT data (NULL values) **Fix:** Only save years that have actual financial data --- ## πŸ” What Was Happening ### Database Before Fix: ```sql org_nr | year | revenue | source 999059198 | 2024 | 830956032 | regnskapsregisteret_api βœ… 999059198 | 2023 | NULL | pdf_scraping ❌ 999059198 | 2022 | NULL | pdf_scraping ❌ ``` **Problem:** Saving years discovered but without data **Result:** Query returns 3 years, but only 1 has useful data --- ## βœ… Fix Applied ### New Logic: ```typescript // ONLY save years with actual data const yearsWithData = scrapedData.filter(d => (d.revenue !== null || d.profit !== null || d.assets !== null) && d.source !== 'needs_manual_import' && d.source !== 'discovered_needs_data' ); // Save only years that have data for (const data of yearsWithData) { db.insertFinancialSnapshot(data); } ``` ### Database After Fix: ```sql org_nr | year | revenue | source 999059198 | 2024 | 830956032 | regnskapsregisteret_api βœ… (Only years with data are saved) ``` --- ## βœ… Cleanup Applied **Removed NULL entries:** ```bash sqlite3 database "DELETE FROM financial_snapshots WHERE revenue IS NULL AND profit IS NULL" ``` **Result:** Database now only contains years with actual data! --- ## 🎯 How It Works Now ### When auto_scrape_financials runs: **Discovers:** - 2024, 2023, 2022, 2021... (13 years found) **Gets Data For:** - 2024: βœ… From API (has data) - 2023-2012: Discovered but needs manual import **Saves to Database:** - ONLY 2024 (the year with data) - Does NOT save empty records **Returns:** ``` βœ… 1 year with data: 2024 πŸ“‹ 12 years discovered: 2023-2012 πŸ’‘ Use build_financial_history to complete ``` --- ## πŸš€ How to Get ALL Years with Data ### Step 1: Discovery (30s - automatic) ``` "Auto-scrape financials for 999059198" β†’ Finds: 13 years β†’ Gets: 2024 data β†’ Saves: Only 2024 to database ``` ### Step 2: Complete Historical (15min - guided) ``` "Build financial history for 999059198" β†’ Shows: CSV template with 2024 pre-filled β†’ You: Download 12 PDFs, fill template β†’ Import: All 13 years β†’ Database: Now has 13 years with data ``` ### Step 3: Analysis (instant - forever) ``` "Analyze financials for 999059198" β†’ Database: Has 13 years β†’ Returns: Complete 13-year analysis ``` --- ## βœ… Database Now Clean **Only contains:** - Years with actual financial data - No NULL revenue/profit entries - Clean for queries **Benefits:** - Faster queries - Accurate counts - No confusion about "years without data" --- ## 🎊 Summary **Issue:** Database had years but no data (NULLs) **Fix:** Only save years with actual data **Cleanup:** Removed existing NULL entries **Result:** Database retrieval now works correctly! **Test:** `"Analyze financials for 999059198"` β†’ Should only show years with actual data (just 2024 for now) **To get more:** Use `build_financial_history` to add historical years with data!

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/josuekongolo/companyiq-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server