Skip to content
Back to skills

1000 Group Document Metrics Date Format Fix Bfaa8533

ASecurity

**Version:** 0.230.048 **Fixed in:** 0.230.048

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
developmentjavascriptpythonjavatestingapidatabasefrontendbackend

Works with

  • api

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 1000-group_document_metrics_date_format_fix_bfaa8533 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 1000 Group Document Metrics Date Format Fix Bfaa8533?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 1000 Group Document Metrics Date Format Fix Bfaa8533
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-1000-group-document-metrics-date-format-fix-bfaa85/badge)](https://www.skillsdirectory.com/skills/tools-only-1000-group-document-metrics-date-format-fix-bfaa85)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# Group Document Metrics Date Format Fix

**Version:** 0.230.048  
**Fixed in:** 0.230.048

## Issue Description

Group document metrics in the Control Center were displaying "Last Day: 0" (count format) instead of "Last Day: 09/02/2025" (date format) like user document metrics. The user requested that group metrics follow the same format as user metrics showing actual dates instead of counts.

## Root Cause Analysis

The backend was providing two different data structures:
- **Users**: `last_day_upload` (singular) - a date string like "09/02/2025" 
- **Groups**: `last_day_uploads` (plural) - a count like `0` or `1`

The frontend group metrics function was using the count-based field instead of calculating and displaying the actual date of the last upload.

## Technical Solution

### Backend Changes (`route_backend_control_center.py`)

Added `last_day_upload` calculation logic to the `enhance_group_with_activity()` function:

1. **Query for Most Recent Upload**: Added database query to find the most recent document upload for each group
2. **Date Format Conversion**: Added logic to convert various date formats (ISO, date-only) to MM/DD/YYYY format
3. **Error Handling**: Added proper error handling for invalid dates with fallback to 'Never'
4. **Debug Logging**: Added comprehensive debug logging for troubleshooting

```python
# Calculate last_day_upload date string (matching user format)
last_upload_query = """
    SELECT TOP 1 c.upload_date, c.created_at, c.modified_at
    FROM c 
    WHERE c.group_id = @group_id 
    ORDER BY c.upload_date DESC, c.created_at DESC, c.modified_at DESC
"""
# ... date parsing and formatting logic
enhanced['activity']['document_metrics']['last_day_upload'] = last_day_upload
```

### Frontend Changes (`control-center.js`)

Updated `renderGroupDocumentMetrics()` function:

1. **Field Change**: Changed from `docMetrics.last_day_uploads` (count) to `docMetrics.last_day_upload` (date string)
2. **Display Logic**: Updated to show date strings like "09/02/2025" or "Never" instead of counts
3. **Validation Logic**: Updated empty state detection to check for 'Never' instead of count === 0

```javascript
const lastDayUpload = docMetrics.last_day_upload || 'Never';
// Display: <div><strong>Last Day:</strong> ${lastDayUpload}</div>
```

## Expected Display Format

Groups now display document metrics in the same format as users:

```
Last Day: 09/02/2025
Total Docs: 1
AI Search: 400 KB  
Storage: 815.6 KB
(Enhanced)
```

## Testing

Created comprehensive functional test (`test_group_document_metrics_display.py`) that validates:

- ✅ Backend provides `last_day_upload` field for groups
- ✅ Frontend JavaScript uses correct field name
- ✅ HTML template calls updated function  
- ✅ API endpoint structure supports new field

## Files Modified

1. **Backend**: `application/single_app/route_backend_control_center.py` - Added date calculation logic
2. **Frontend JS**: `application/single_app/static/js/control-center.js` - Updated display function
3. **Config**: `application/single_app/config.py` - Version increment to 0.230.048
4. **Test**: `functional_tests/test_group_document_metrics_display.py` - Validation test

## Validation Results

All functional tests pass ✅:
- Backend Group Metrics Logic: PASSED
- Control Center JavaScript Structure: PASSED  
- Control Center HTML Structure: PASSED
- Group Document Metrics API Structure: PASSED

The fix ensures group document metrics now display in the exact same format as user document metrics, showing actual dates instead of counts for the "Last Day" field.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.