Add unique IP count and duplicate detection to sites page
The sites page previously showed total IP count which included duplicates across multiple sites, leading to inflated numbers. Now displays unique IP count as the primary metric with duplicate count shown when present. - Add get_global_ip_stats() method to SiteService for unique/duplicate counts - Update /api/sites?all=true endpoint to include IP statistics - Update sites.html to display unique IPs with optional duplicate indicator - Update API documentation with new response fields 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -117,7 +117,7 @@ Retrieve a paginated list of all sites.
|
||||
| `per_page` | integer | No | 20 | Items per page (1-100) |
|
||||
| `all` | string | No | - | Set to "true" to return all sites without pagination |
|
||||
|
||||
**Success Response (200 OK):**
|
||||
**Success Response (200 OK) - Paginated:**
|
||||
```json
|
||||
{
|
||||
"sites": [
|
||||
@@ -139,13 +139,40 @@ Retrieve a paginated list of all sites.
|
||||
}
|
||||
```
|
||||
|
||||
**Success Response (200 OK) - All Sites (all=true):**
|
||||
```json
|
||||
{
|
||||
"sites": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Production DC",
|
||||
"description": "Production datacenter servers",
|
||||
"ip_count": 25,
|
||||
"created_at": "2025-11-19T10:30:00Z",
|
||||
"updated_at": "2025-11-19T10:30:00Z"
|
||||
}
|
||||
],
|
||||
"total_ips": 100,
|
||||
"unique_ips": 85,
|
||||
"duplicate_ips": 15
|
||||
}
|
||||
```
|
||||
|
||||
**Response Fields (all=true):**
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `total_ips` | integer | Total count of IP entries across all sites (including duplicates) |
|
||||
| `unique_ips` | integer | Count of distinct IP addresses |
|
||||
| `duplicate_ips` | integer | Number of duplicate IP entries (total_ips - unique_ips) |
|
||||
|
||||
**Usage Example:**
|
||||
```bash
|
||||
# List first page
|
||||
curl -X GET http://localhost:5000/api/sites \
|
||||
-b cookies.txt
|
||||
|
||||
# Get all sites (for dropdowns)
|
||||
# Get all sites with global IP stats
|
||||
curl -X GET "http://localhost:5000/api/sites?all=true" \
|
||||
-b cookies.txt
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user