master - part 2

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-30 09:47:58 +00:00
parent 2af7bb725f
commit 885158e152
13 changed files with 538 additions and 63 deletions

View File

@@ -852,6 +852,35 @@ export async function bulkUpdateClustersStatus(ids: number[], status: string): P
});
}
export interface ClustersSummary {
total_clusters: number;
total_keywords: number;
total_volume: number;
}
export async function fetchClustersSummary(sectorId?: number): Promise<ClustersSummary> {
const params = new URLSearchParams();
// Auto-add site filter
const activeSiteId = getActiveSiteId();
if (activeSiteId) {
params.append('site_id', activeSiteId.toString());
}
// Add sector filter if provided or get active
if (sectorId !== undefined) {
params.append('sector_id', sectorId.toString());
} else {
const activeSectorId = getActiveSectorId();
if (activeSectorId !== null && activeSectorId !== undefined) {
params.append('sector_id', activeSectorId.toString());
}
}
const queryString = params.toString();
return fetchAPI(`/v1/planner/clusters/summary/${queryString ? `?${queryString}` : ''}`);
}
export async function autoClusterKeywords(keywordIds: number[], sectorId?: number): Promise<{ success: boolean; task_id?: string; clusters_created?: number; keywords_updated?: number; message?: string; error?: string }> {
const endpoint = `/v1/planner/keywords/auto_cluster/`;
const requestBody = { ids: keywordIds, sector_id: sectorId };