Coverage for mindsdb / integrations / handlers / gong_handler / constants.py: 0%
5 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-21 00:36 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-21 00:36 +0000
1"""
2Constants and metadata for the Gong handler.
3"""
6def get_gong_api_info(handler_name: str) -> str:
7 return f"""
8 # Gong Handler Usage Guide: {handler_name}
10 ## CRITICAL Performance Requirements
12 **ALWAYS use date filters on analytics and (ideally) on calls/transcripts**
13 - Analytics defaults to last 7 days if no date filters are provided
14 - Calls/transcripts can be very large; add WHERE date ... or call_id filters
15 - Example: WHERE c.date >= '2024-01-01' AND c.date < '2024-01-31'
17 **ALWAYS use LIMIT with transcripts**
18 - Transcripts can contain thousands of rows per call
19 - Example: LIMIT 100
21 **Query by call_id when fetching transcripts**
22 - First get call IDs from `calls` (with date filters), then fetch transcripts for those IDs
23 - Avoids massive data transfers
25 ## Query Strategy by User Intent
27 **"calls" / "meetings"** → query `{handler_name}.calls`
29 **"sentiment" / "topics" / "what was discussed"** → query `{handler_name}.analytics` JOIN `{handler_name}.calls`
30 - Analytics contains AI-generated insights about call content
32 **"what did X say" / keyword search in speech** → query `{handler_name}.transcripts` JOIN `{handler_name}.calls`
33 - Transcripts contain exact words spoken
34 - Always filter by call_id and/or a narrow date range
36 **"sales reps" / "users" / "team"** → query `{handler_name}.users`
37 - Independent table, no JOIN needed
39 ## Efficient JOIN Pattern
41 Start with the smallest, filtered dataset first:
42 ```sql
43 SELECT c.title, a.sentiment_score
44 FROM {handler_name}.calls c
45 JOIN {handler_name}.analytics a ON c.call_id = a.call_id
46 WHERE c.date >= '2024-01-01' AND c.date < '2024-02-01'
47 LIMIT 50;
48 ```
49 """
52GONG_TABLES_METADATA = {
53 "calls": {
54 "name": "calls",
55 "type": "api_table",
56 "description": "Call records from Gong with basic metadata including date, duration, participants, and status",
57 "columns": [
58 {"name": "call_id", "type": "str", "description": "Unique identifier for the call"},
59 {"name": "title", "type": "str", "description": "Call title or subject"},
60 {"name": "date", "type": "str", "description": "Call date (ISO 8601 format, YYYY-MM-DD)"},
61 {"name": "duration", "type": "int", "description": "Call duration in seconds"},
62 {"name": "recording_url", "type": "str", "description": "URL to the call recording (if available)"},
63 {"name": "call_type", "type": "str", "description": "Call type/system classification"},
64 {"name": "user_id", "type": "str", "description": "Primary user/owner of the call"},
65 {"name": "participants", "type": "str", "description": "Comma-separated list of call participants"},
66 {"name": "status", "type": "str", "description": "Call status (scheduled, completed, etc.)"},
67 ],
68 "filterable_columns": ["date", "status"],
69 "api_endpoint": "/v2/calls",
70 "supports_pagination": True,
71 },
72 "users": {
73 "name": "users",
74 "type": "api_table",
75 "description": "User information including names, emails, roles, and permissions",
76 "columns": [
77 {"name": "user_id", "type": "str", "description": "Unique identifier for the user"},
78 {"name": "name", "type": "str", "description": "User's full name"},
79 {"name": "email", "type": "str", "description": "User's email address"},
80 {"name": "role", "type": "str", "description": "User's role in the organization"},
81 {"name": "permissions", "type": "str", "description": "User's permission levels"},
82 {"name": "status", "type": "str", "description": "User status (active/inactive)"},
83 ],
84 "filterable_columns": ["email", "status"],
85 "api_endpoint": "/v2/users",
86 "supports_pagination": True,
87 },
88 "analytics": {
89 "name": "analytics",
90 "type": "api_table",
91 "description": "Advanced call analytics including sentiment analysis, topics, key phrases, and interaction scores",
92 "columns": [
93 {"name": "call_id", "type": "str", "description": "Unique identifier for the call"},
94 {"name": "sentiment_score", "type": "float", "description": "Overall sentiment score (0-1)"},
95 {"name": "topic_score", "type": "float", "description": "Topic relevance score (0-1)"},
96 {"name": "key_phrases", "type": "str", "description": "Comma-separated list of key phrases identified"},
97 {"name": "topics", "type": "str", "description": "Comma-separated list of topics discussed"},
98 {"name": "emotions", "type": "str", "description": "Emotional analysis metrics"},
99 {"name": "confidence_score", "type": "str", "description": "AI confidence score for analytics"},
100 ],
101 "filterable_columns": ["date"],
102 "api_endpoint": "/v2/calls/extensive",
103 "supports_pagination": True,
104 "notes": "Defaults to last 7 days if no date filters are provided.",
105 },
106 "transcripts": {
107 "name": "transcripts",
108 "type": "api_table",
109 "description": "Call transcripts with speaker identification, timestamps, and confidence scores",
110 "columns": [
111 {"name": "call_id", "type": "str", "description": "Unique identifier for the call"},
112 {"name": "speaker", "type": "str", "description": "Speaker identifier"},
113 {"name": "timestamp", "type": "int", "description": "Timestamp in milliseconds from call start"},
114 {"name": "text", "type": "str", "description": "Transcript text for this segment"},
115 {"name": "confidence", "type": "float", "description": "Transcription confidence score"},
116 {"name": "segment_id", "type": "str", "description": "Unique segment identifier"},
117 ],
118 "filterable_columns": ["call_id", "text"],
119 "api_endpoint": "/v2/calls/transcript",
120 "supports_pagination": True,
121 "notes": "Fetch transcripts for specific call IDs; always filter by call_id and/or narrow date range.",
122 },
123}
126GONG_PRIMARY_KEYS = {
127 "calls": {"column_name": "call_id", "constraint_name": "pk_calls_call_id"},
128 "users": {"column_name": "user_id", "constraint_name": "pk_users_user_id"},
129 "analytics": {"column_name": "call_id", "constraint_name": "pk_analytics_call_id"},
130 "transcripts": {"column_name": "segment_id", "constraint_name": "pk_transcripts_segment_id"},
131}
133GONG_FOREIGN_KEYS = {
134 "analytics": [
135 {
136 "column_name": "call_id",
137 "foreign_table_name": "calls",
138 "foreign_column_name": "call_id",
139 "constraint_name": "fk_analytics_call_id",
140 }
141 ],
142 "transcripts": [
143 {
144 "column_name": "call_id",
145 "foreign_table_name": "calls",
146 "foreign_column_name": "call_id",
147 "constraint_name": "fk_transcripts_call_id",
148 }
149 ],
150}