* Get mapping statistics
()
| 284 | * Get mapping statistics |
| 285 | */ |
| 286 | async getStats(): Promise<SlackMappingStats> { |
| 287 | const result = await query<{ |
| 288 | total: string; |
| 289 | mapped: string; |
| 290 | unmapped: string; |
| 291 | pending_verification: string; |
| 292 | bots: string; |
| 293 | deleted: string; |
| 294 | opted_out: string; |
| 295 | }>( |
| 296 | `SELECT |
| 297 | COUNT(*)::text AS total, |
| 298 | COUNT(*) FILTER (WHERE mapping_status = 'mapped')::text AS mapped, |
| 299 | COUNT(*) FILTER (WHERE mapping_status = 'unmapped' AND slack_is_bot = false AND slack_is_deleted = false)::text AS unmapped, |
| 300 | COUNT(*) FILTER (WHERE mapping_status = 'pending_verification')::text AS pending_verification, |
| 301 | COUNT(*) FILTER (WHERE slack_is_bot = true)::text AS bots, |
| 302 | COUNT(*) FILTER (WHERE slack_is_deleted = true)::text AS deleted, |
| 303 | COUNT(*) FILTER (WHERE nudge_opt_out = true)::text AS opted_out |
| 304 | FROM slack_user_mappings` |
| 305 | ); |
| 306 | |
| 307 | const row = result.rows[0]; |
| 308 | return { |
| 309 | total: parseInt(row.total, 10), |
| 310 | mapped: parseInt(row.mapped, 10), |
| 311 | unmapped: parseInt(row.unmapped, 10), |
| 312 | pending_verification: parseInt(row.pending_verification, 10), |
| 313 | bots: parseInt(row.bots, 10), |
| 314 | deleted: parseInt(row.deleted, 10), |
| 315 | opted_out: parseInt(row.opted_out, 10), |
| 316 | }; |
| 317 | } |
| 318 | |
| 319 | // ============== Nudge Tracking ============== |
| 320 |
no outgoing calls
no test coverage detected