Skip to content

Commit 2fa62a2

Browse files
committed
BE: DEEP_SLEEP #1555 co-author @legionGer
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
2 parents 604a831 + 80bb53a commit 2fa62a2

31 files changed

Lines changed: 442 additions & 262 deletions

.github/skills/code-standards/SKILL.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ Use sanitizers from `server/helper.py` before storing user input. MAC addresses
7474
- Everything is already writable
7575
- If permissions needed, fix `.devcontainer/scripts/setup.sh`
7676

77+
## Test Helpers — No Duplicate Mocks
78+
79+
Reuse shared mocks and factories from `test/db_test_helpers.py`. Never redefine `DummyDB`, `make_db`, or inline DDL in individual test files.
80+
81+
```python
82+
import sys, os
83+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
84+
from db_test_helpers import make_db, DummyDB, insert_device, minutes_ago
85+
```
86+
87+
If a helper you need doesn't exist yet, add it to `db_test_helpers.py` — not locally in the test file.
88+
7789
## Path Hygiene
7890

7991
- Use environment variables for runtime paths

docs/PERFORMANCE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Frequent scans increase resource usage, network traffic, and database read/write
8787
* **Increase scan intervals** (`<PLUGIN>_RUN_SCHD`) on busy networks or low-end hardware.
8888
* **Increase timeouts** (`<PLUGIN>_RUN_TIMEOUT`) to avoid plugin failures.
8989
* **Reduce subnet size** – e.g., use `/24` instead of `/16` to reduce scan load.
90+
* **Enable the deep sleep setting** (`DEEP_SLEEP`) – Lowers CPU usage by extending idle wait times between processing cycles. When enabled, scans may be delayed by up to 1 minute and the UI might become less responsive.
9091

9192
Some plugins also include options to limit which devices are scanned. If certain plugins consistently run long, consider narrowing their scope.
9293

front/css/app.css

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,15 +1413,48 @@ textarea[readonly],
14131413

14141414

14151415
#columnFilters {
1416-
display: flex;
1417-
flex-wrap: wrap;
1418-
gap: 10px; /* Add spacing between items */
1416+
display: grid;
1417+
grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
1418+
gap: 0.75em;
1419+
padding: 0.5em 0;
1420+
}
1421+
1422+
#columnFilters::before,
1423+
#columnFilters::after {
1424+
display: none !important;
14191425
}
14201426

14211427
.filter-group {
1422-
box-sizing: border-box; /* Ensure padding and borders are included in the width */
1423-
padding: 1em;
1424-
padding-top: 0;
1428+
box-sizing: border-box;
1429+
padding: 0.4em;
1430+
margin: 0;
1431+
border-radius: 3px;
1432+
display: flex;
1433+
flex-direction: column;
1434+
align-items: stretch;
1435+
gap: 0.15em;
1436+
white-space: normal;
1437+
}
1438+
1439+
.filter-group label {
1440+
box-sizing: border-box;
1441+
margin: 0;
1442+
border-radius: 3px;
1443+
display: flex;
1444+
flex-direction: column;
1445+
align-items: stretch;
1446+
gap: 0.15em;
1447+
white-space: normal;
1448+
padding-left: 15px;
1449+
padding-right: 0px;
1450+
}
1451+
1452+
.filter-dropdown {
1453+
width: 100%;
1454+
}
1455+
.filter-group select {
1456+
margin-left: 15px;
1457+
padding-right: 0px;
14251458
}
14261459

14271460
.filter-dropdown

front/devices.php

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -430,29 +430,35 @@ function initFilters() {
430430
filters: []
431431
};
432432

433-
// Group data by columnName
434-
resultJSON.forEach(entry => {
435-
const existingFilter = transformed.filters.find(filter => filter.column === entry.columnName);
436-
437-
if (existingFilter) {
438-
// Add the unique columnValue to options if not already present
439-
if (!existingFilter.options.some(opt => opt.value === entry.columnValue)) {
440-
existingFilter.options.push({
441-
value: entry.columnValue,
442-
label: entry.columnLabel || entry.columnValue
443-
});
433+
// Build filters in the exact order of columnFilters
434+
columnFilters.forEach(([columnName, headerKey]) => {
435+
// Get matching entries for this column
436+
const entries = resultJSON.filter(e => e.columnName === columnName);
437+
438+
if (entries.length === 0) return;
439+
440+
// Build options (unique)
441+
const optionsMap = new Map();
442+
443+
entries.forEach(entry => {
444+
const value = entry.columnValue;
445+
const label = entry.columnLabel || value;
446+
447+
if (!optionsMap.has(value)) {
448+
optionsMap.set(value, { value, label });
444449
}
445-
} else {
446-
// Create a new filter entry
447-
transformed.filters.push({
448-
column: entry.columnName,
449-
headerKey: entry.columnHeaderStringKey,
450-
options: [{
451-
value: entry.columnValue,
452-
label: entry.columnLabel || entry.columnValue
453-
}]
454-
});
455-
}
450+
});
451+
452+
const options = Array.from(optionsMap.values());
453+
454+
// Sort options alphabetically
455+
options.sort((a, b) => a.label.localeCompare(b.label));
456+
457+
transformed.filters.push({
458+
column: columnName,
459+
headerKey: headerKey,
460+
options: options
461+
});
456462
});
457463

458464
// Sort options alphabetically by label for better readability

front/php/templates/language/ar_ar.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
"CustProps_cant_remove": "لا يمكن إزالة الخاصية المخصصة",
6767
"DAYS_TO_KEEP_EVENTS_description": "عدد الأيام للاحتفاظ بسجلات الأحداث",
6868
"DAYS_TO_KEEP_EVENTS_name": "مدة الاحتفاظ بالأحداث",
69+
"DEEP_SLEEP_description": "",
70+
"DEEP_SLEEP_name": "",
6971
"DISCOVER_PLUGINS_description": "اكتشاف المكونات الإضافية المتاحة",
7072
"DISCOVER_PLUGINS_name": "اكتشاف المكونات الإضافية",
7173
"DevDetail_Children_Title": "علاقات الأطفال",

front/php/templates/language/ca_ca.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
"CustProps_cant_remove": "No es pot eliminar, es necessita una propietat mínim.",
6767
"DAYS_TO_KEEP_EVENTS_description": "Això és una configuració de manteniment. Especifica el nombre de dies que es conservaran els esdeveniments. Els esdeveniments antics s'esborraran periòdicament. També aplica als esdeveniments dels Connectors (Plugins).",
6868
"DAYS_TO_KEEP_EVENTS_name": "Esborrar esdeveniments més vells de",
69+
"DEEP_SLEEP_description": "",
70+
"DEEP_SLEEP_name": "",
6971
"DISCOVER_PLUGINS_description": "Desactiva aquesta opció per accelerar la inicialització i l'estalvi de configuració. Quan està desactivat, els connectors no es descobreixen, i no podeu afegir nous connectors a la configuració <code>LOADED_PLUGINS</code>.",
7072
"DISCOVER_PLUGINS_name": "Descobreix els plugins",
7173
"DevDetail_Children_Title": "Relacions filles",

0 commit comments

Comments
 (0)