
    ;j	                        S SK Jr  S SKrS SKrS SKJr  S SKJr  \" \5      R                  S-  r
Sr\
4SS jjr\
4SS jjr\S	:X  a  \" 5         \" S
\" 5        35        gg)    )annotationsN)Path)load_all_projectszemail_agent.dba  
CREATE TABLE IF NOT EXISTS product_catalog (
  project_id TEXT PRIMARY KEY,
  title TEXT NOT NULL,
  status TEXT,
  target_industries TEXT NOT NULL,
  customer_problem TEXT,
  potential_score REAL,
  confidence TEXT,
  source_file TEXT NOT NULL,
  synced_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS lead_project_matches (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  contact_id INTEGER NOT NULL,
  project_id TEXT NOT NULL,
  industry_fit REAL NOT NULL DEFAULT 0,
  problem_pressure REAL NOT NULL DEFAULT 0,
  company_fit REAL NOT NULL DEFAULT 0,
  technical_fit REAL NOT NULL DEFAULT 0,
  economic_value REAL NOT NULL DEFAULT 0,
  reachability REAL NOT NULL DEFAULT 0,
  evidence_quality REAL NOT NULL DEFAULT 0,
  sale_probability REAL NOT NULL DEFAULT 0,
  lead_score REAL NOT NULL DEFAULT 0,
  rationale TEXT,
  evidence_json TEXT,
  status TEXT NOT NULL DEFAULT 'researched',
  human_gate TEXT NOT NULL DEFAULT 'pending',
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  UNIQUE(contact_id, project_id)
);
CREATE INDEX IF NOT EXISTS idx_lpm_score ON lead_project_matches(lead_score DESC);
CREATE INDEX IF NOT EXISTS idx_lpm_gate ON lead_project_matches(human_gate, status);
c                    [         R                  " U 5       nUR                  [        5        UR	                  5         S S S 5        g ! , (       d  f       g = f)N)sqlite3connectexecutescriptSCHEMAcommit)db_pathconns     /app/v2_schema.pyinit_schemar   0   s3    		!T6" 
"	!	!s   &A
Ac           
        [        5       n[        R                  " U 5       nU H  nUR                  UR                  UR
                  [        R                  " UR                  SS9UR                  UR                  UR                  UR                  4nUR                  SU5        M     UR                  5         S S S 5        [        U5      $ ! , (       d  f       N= f)NF)ensure_asciizINSERT OR REPLACE INTO product_catalog (project_id,title,status,target_industries,customer_problem,potential_score,confidence,source_file,synced_at) VALUES (?,?,?,?,?,?,?,?,CURRENT_TIMESTAMP))r   r   r   
project_idtitlestatusjsondumpstarget_industriescustomer_problempotential_score
confidencesource_fileexecuter   len)r   projectsr   pvaluess        r   sync_projectsr!   6   s     "H		!TAaggqxx

1..UC""A$5$5amm	F LL= ?E	  	 
" x= 
"	!s   BC
C__main__zsynced_projects=)r   r   returnNone)r   r   r#   int)
__future__r   r   r   pathlibr   project_catalogr   __file__parentDB_PATHr
   r   r!   __name__print     r   <module>r0      sl    "    -
x.

"2
2#
L !(  #* ( zM	]_-
./ r/   