-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
76 lines (56 loc) · 2.09 KB
/
Copy pathmodels.py
File metadata and controls
76 lines (56 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Typed data models for the rank tracker.
`RankCheckConfig` describes *what* to check; `RankResult` describes *what we found*.
Keeping these as Pydantic models means malformed API responses surface as
validation errors instead of silent corruption downstream.
"""
from __future__ import annotations
from datetime import datetime, timezone
from typing import List, Optional
from pydantic import BaseModel, Field
class RankCheckConfig(BaseModel):
keyword: str
target_domain: str
target_url: Optional[str] = None
search_engine: str = "google"
locale: str = "en-us"
google_results_language: str = "en"
geo: str = "United States"
device_type: str = "desktop"
pages: int = 1
top_n: int = 10 # how many competitor results to capture per check
active: bool = True # set False to keep history without paying for new checks
frequency: str = "daily" # one of: daily, weekly, monthly, paused
class AIOverviewCitation(BaseModel):
url: str
title: str = ""
source: str = ""
position: int
class CompetitorEntry(BaseModel):
"""One organic SERP row, kept so we can show 'you vs. who's above you'."""
position: int
url: str
domain: str
title: str = ""
class RankResult(BaseModel):
keyword: str
target_domain: str
organic_position: Optional[int] = None
matched_url: Optional[str] = None
featured_snippet: bool = False
featured_snippet_owned: bool = False
ai_overview_present: bool = False
ai_overview_cited: bool = False
ai_overview_citation_rank: Optional[int] = None
ai_overview_citations: List[AIOverviewCitation] = Field(default_factory=list)
paa_present: bool = False
paa_question_count: int = 0
local_pack_present: bool = False
knowledge_panel_present: bool = False
location: str = ""
device: str = ""
locale: str = ""
total_results: Optional[int] = None
serp_url: Optional[str] = None
raw_organic_count: int = 0
top_results: List[CompetitorEntry] = Field(default_factory=list)
timestamp: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))