Conservazione in Sidebar
This commit is contained in:
@@ -2,12 +2,14 @@
|
||||
* API client per le impostazioni del tenant.
|
||||
*
|
||||
* Endpoint:
|
||||
* GET /api/v1/settings -> legge configurazione (admin)
|
||||
* PUT /api/v1/settings -> aggiorna configurazione (admin)
|
||||
* GET /api/v1/settings/indexing/stats -> statistiche indicizzazione
|
||||
* GET /api/v1/settings/indexing/status -> stato job reindex
|
||||
* POST /api/v1/settings/indexing/reindex -> avvia reindex
|
||||
* DELETE /api/v1/settings/indexing/reindex -> cancella reindex
|
||||
* GET /api/v1/settings -> legge configurazione (admin)
|
||||
* PUT /api/v1/settings -> aggiorna configurazione (admin)
|
||||
* GET /api/v1/settings/indexing/stats -> statistiche indicizzazione
|
||||
* GET /api/v1/settings/indexing/status -> stato job reindex
|
||||
* POST /api/v1/settings/indexing/reindex -> avvia reindex
|
||||
* DELETE /api/v1/settings/indexing/reindex -> cancella reindex
|
||||
* GET /api/v1/settings/conservation/stats -> statistiche conservazione
|
||||
* POST /api/v1/settings/conservation/trigger -> avvia job conservazione manuale
|
||||
*/
|
||||
|
||||
import { apiClient } from './client'
|
||||
@@ -83,6 +85,35 @@ export interface IndexingJobStatus {
|
||||
error: string | null
|
||||
}
|
||||
|
||||
// ─── Tipi conservazione sostitutiva ───────────────────────────────────────
|
||||
|
||||
export interface ConservationStats {
|
||||
total_messages: number
|
||||
conserved: number
|
||||
pending: number
|
||||
not_queued: number
|
||||
coverage_pct: number // 0-100
|
||||
last_conserved_at: string | null // ISO datetime
|
||||
}
|
||||
|
||||
export interface ConservationTenantBreakdown {
|
||||
tenant_id: string
|
||||
tenant_name: string
|
||||
tenant_slug: string
|
||||
stats: ConservationStats
|
||||
}
|
||||
|
||||
export interface ConservationStatsResponse {
|
||||
stats: ConservationStats
|
||||
per_tenant: ConservationTenantBreakdown[] | null
|
||||
}
|
||||
|
||||
export interface ConservationTriggerResult {
|
||||
queued: boolean
|
||||
message: string
|
||||
job_id: string | null
|
||||
}
|
||||
|
||||
// ─── Client impostazioni generali ──────────────────────────────────────────
|
||||
|
||||
export const settingsApi = {
|
||||
@@ -211,4 +242,32 @@ export const settingsApi = {
|
||||
)
|
||||
return data
|
||||
},
|
||||
|
||||
// ── Conservazione sostitutiva ─────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Restituisce le statistiche di conservazione sostitutiva.
|
||||
* admin: stats del proprio tenant.
|
||||
* super_admin senza tenantId: stats aggregate su tutti i tenant + per_tenant.
|
||||
* super_admin con tenantId: stats del tenant specificato.
|
||||
*/
|
||||
getConservationStats: async (tenantId?: string): Promise<ConservationStatsResponse> => {
|
||||
const params = tenantId ? { tenant_id: tenantId } : undefined
|
||||
const { data } = await apiClient.get<ConservationStatsResponse>(
|
||||
'/settings/conservation/stats',
|
||||
{ params }
|
||||
)
|
||||
return data
|
||||
},
|
||||
|
||||
/**
|
||||
* Avvia manualmente il job di conservazione sostitutiva.
|
||||
* Il job verra' eseguito dal worker entro pochi secondi.
|
||||
*/
|
||||
triggerConservation: async (): Promise<ConservationTriggerResult> => {
|
||||
const { data } = await apiClient.post<ConservationTriggerResult>(
|
||||
'/settings/conservation/trigger'
|
||||
)
|
||||
return data
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user