mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-05-02 03:22:40 +02:00
refactor(contacts): Remove path_len filter from cleanup tool
Remove impractical path length filter from contact cleanup feature. The out_path_len parameter is rarely useful as most contacts have value -1 (no route), making this filter unpractical for real-world use. Changes: - Remove path_len parameter from backend API endpoints - Remove path length input field from HTML template - Remove path_len collection from JavaScript code - Update documentation (CLAUDE.md, README.md) - Simplify cleanup filter to: name, types, date field, and days Backend changes: - Update _filter_contacts_by_criteria() to remove path_len logic - Remove path_len validation from both endpoints - Update API documentation in docstrings Frontend changes: - Remove Path Length input section from contacts-manage.html - Remove path_len from collectCleanupCriteria() function Documentation changes: - Update API endpoint descriptions in CLAUDE.md - Update cleanup instructions in README.md - Remove path_len from example use cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,7 @@ A lightweight web interface for meshcore-cli, providing browser-based access to
|
||||
- **Smart filtering:** Search by name/key, filter by contact type (CLI, REP, ROOM, SENS)
|
||||
- **Activity indicators:** Visual status icons (🟢 active, 🟡 recent, 🔴 inactive) based on last advertisement
|
||||
- **GPS location:** View contact location on Google Maps (when GPS coordinates available)
|
||||
- **Advanced cleanup tool:** Filter and remove contacts by name, type (CLI/REP/ROOM/SENS), inactivity period, and path length with preview before deletion
|
||||
- **Advanced cleanup tool:** Filter and remove contacts by name, type (CLI/REP/ROOM/SENS), and inactivity period with preview before deletion
|
||||
- 📦 **Message archiving** - Automatic daily archiving with browse-by-date selector
|
||||
- ⚡ **Efficient polling** - Lightweight update checks every 10s, UI refreshes only when needed
|
||||
- 📡 **Network commands** - Send advertisement (advert) or flood advertisement (floodadv) for network management
|
||||
@@ -486,14 +486,12 @@ The advanced cleanup tool allows you to filter and remove contacts based on mult
|
||||
- **Contact Types:** Select which types to include (CLI, REP, ROOM, SENS)
|
||||
- **Date Field:** Choose between "Last Advert" (recommended) or "Last Modified"
|
||||
- **Days of Inactivity:** Contacts inactive for more than X days (0 = ignore)
|
||||
- **Path Length >:** Contacts with path length greater than X (0 = ignore)
|
||||
4. Click **Preview Cleanup** to see matching contacts
|
||||
5. Review the list and confirm deletion
|
||||
|
||||
**Example use cases:**
|
||||
- Remove all REP contacts inactive for 30+ days: Select REP, set days to 30
|
||||
- Clean specific contact names: Enter partial name (e.g., "test")
|
||||
- Remove distant contacts: Set path length > 5
|
||||
|
||||
### Network Commands
|
||||
|
||||
|
||||
@@ -267,7 +267,6 @@ def _filter_contacts_by_criteria(contacts: list, criteria: dict) -> list:
|
||||
- types (list[int]): Contact types to include [1,2,3,4]
|
||||
- date_field (str): "last_advert" or "lastmod"
|
||||
- days (int): Days of inactivity (0 = ignore)
|
||||
- path_len (int): Minimum path length, >X (0 = ignore)
|
||||
|
||||
Returns:
|
||||
List of contacts matching criteria
|
||||
@@ -276,7 +275,6 @@ def _filter_contacts_by_criteria(contacts: list, criteria: dict) -> list:
|
||||
selected_types = criteria.get('types', [1, 2, 3, 4])
|
||||
date_field = criteria.get('date_field', 'last_advert')
|
||||
days = criteria.get('days', 0)
|
||||
path_len = criteria.get('path_len', 0)
|
||||
|
||||
# Calculate timestamp threshold for days filter
|
||||
current_time = int(time.time())
|
||||
@@ -307,12 +305,6 @@ def _filter_contacts_by_criteria(contacts: list, criteria: dict) -> list:
|
||||
# Still active within threshold
|
||||
continue
|
||||
|
||||
# Filter by path length (> path_len)
|
||||
if path_len > 0:
|
||||
contact_path_len = contact.get('out_path_len', -1)
|
||||
if contact_path_len <= path_len:
|
||||
continue
|
||||
|
||||
# Contact matches all criteria
|
||||
filtered.append(contact)
|
||||
|
||||
@@ -329,8 +321,7 @@ def preview_cleanup_contacts():
|
||||
"name_filter": "", # Partial name match (empty = ignore)
|
||||
"types": [1, 2, 3, 4], # Contact types (1=CLI, 2=REP, 3=ROOM, 4=SENS)
|
||||
"date_field": "last_advert", # "last_advert" or "lastmod"
|
||||
"days": 2, # Days of inactivity (0 = ignore)
|
||||
"path_len": 0 # Path length > X (0 = ignore)
|
||||
"days": 2 # Days of inactivity (0 = ignore)
|
||||
}
|
||||
|
||||
Returns:
|
||||
@@ -349,8 +340,7 @@ def preview_cleanup_contacts():
|
||||
'name_filter': data.get('name_filter', ''),
|
||||
'types': data.get('types', [1, 2, 3, 4]),
|
||||
'date_field': data.get('date_field', 'last_advert'),
|
||||
'days': data.get('days', 0),
|
||||
'path_len': data.get('path_len', 0)
|
||||
'days': data.get('days', 0)
|
||||
}
|
||||
|
||||
# Validate types
|
||||
@@ -374,12 +364,6 @@ def preview_cleanup_contacts():
|
||||
'error': 'Invalid days (must be non-negative integer)'
|
||||
}), 400
|
||||
|
||||
if not isinstance(criteria['path_len'], int) or criteria['path_len'] < 0:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': 'Invalid path_len (must be non-negative integer)'
|
||||
}), 400
|
||||
|
||||
# Get all contacts
|
||||
success_detailed, contacts_detailed, error_detailed = cli.get_contacts_with_last_seen()
|
||||
if not success_detailed:
|
||||
@@ -433,8 +417,7 @@ def cleanup_contacts():
|
||||
"name_filter": "", # Partial name match (empty = ignore)
|
||||
"types": [1, 2, 3, 4], # Contact types (1=CLI, 2=REP, 3=ROOM, 4=SENS)
|
||||
"date_field": "last_advert", # "last_advert" or "lastmod"
|
||||
"days": 2, # Days of inactivity (0 = ignore)
|
||||
"path_len": 0 # Path length > X (0 = ignore)
|
||||
"days": 2 # Days of inactivity (0 = ignore)
|
||||
}
|
||||
|
||||
Returns:
|
||||
@@ -457,8 +440,7 @@ def cleanup_contacts():
|
||||
'name_filter': data.get('name_filter', ''),
|
||||
'types': data.get('types', [1, 2, 3, 4]),
|
||||
'date_field': data.get('date_field', 'last_advert'),
|
||||
'days': data.get('days', 0),
|
||||
'path_len': data.get('path_len', 0)
|
||||
'days': data.get('days', 0)
|
||||
}
|
||||
|
||||
# Validate types
|
||||
@@ -482,12 +464,6 @@ def cleanup_contacts():
|
||||
'error': 'Invalid days (must be non-negative integer)'
|
||||
}), 400
|
||||
|
||||
if not isinstance(criteria['path_len'], int) or criteria['path_len'] < 0:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': 'Invalid path_len (must be non-negative integer)'
|
||||
}), 400
|
||||
|
||||
# Get all contacts
|
||||
success_detailed, contacts_detailed, error_detailed = cli.get_contacts_with_last_seen()
|
||||
if not success_detailed:
|
||||
|
||||
@@ -156,7 +156,7 @@ function collectCleanupCriteria() {
|
||||
* Collect cleanup filter criteria from form inputs.
|
||||
*
|
||||
* Returns:
|
||||
* Object with criteria: {name_filter, types, date_field, days, path_len}
|
||||
* Object with criteria: {name_filter, types, date_field, days}
|
||||
*/
|
||||
// Name filter
|
||||
const nameFilter = document.getElementById('cleanupNameFilter')?.value?.trim() || '';
|
||||
@@ -172,15 +172,11 @@ function collectCleanupCriteria() {
|
||||
// Days of inactivity
|
||||
const days = parseInt(document.getElementById('cleanupDays')?.value) || 0;
|
||||
|
||||
// Path length
|
||||
const pathLen = parseInt(document.getElementById('cleanupPathLen')?.value) || 0;
|
||||
|
||||
return {
|
||||
name_filter: nameFilter,
|
||||
types: types,
|
||||
date_field: dateField,
|
||||
days: days,
|
||||
path_len: pathLen
|
||||
days: days
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -135,13 +135,6 @@
|
||||
<input type="number" class="form-control" id="cleanupDays" value="2" min="0">
|
||||
<small class="form-text text-muted">Contacts inactive for more than this many days will be selected</small>
|
||||
</div>
|
||||
|
||||
<!-- Path Length -->
|
||||
<div class="mb-3">
|
||||
<label for="cleanupPathLen" class="form-label">Path Length > (0 = ignore):</label>
|
||||
<input type="number" class="form-control" id="cleanupPathLen" value="0" min="0">
|
||||
<small class="form-text text-muted">Select contacts with path length greater than this value</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-warning" id="cleanupPreviewBtn">
|
||||
|
||||
Reference in New Issue
Block a user