Fix Apprise notification system, scheduler stability, and email configuration

Fixes & Enhancements

* Resolved five critical Apprise notification issues:
  • Ensured configuration reload during scheduled jobs
  • Fixed warranty data fetching for Apprise-only users
  • Refactored notification dispatch logic with dedicated helpers
  • Corrected handler scoping via Flask app context
  • Wrapped scheduler jobs with Flask app context to prevent context errors
  → Verified: Scheduled Apprise notifications now work reliably for "Apprise only" and "Both" channels.

* Added support for SMTP\_FROM\_ADDRESS environment variable, allowing sender address customization independent of SMTP username. (PR #115)

* Fixed duplicate scheduled notifications in multi-worker environments:
  • Strengthened should\_run\_scheduler() logic
  • Now guarantees exactly one scheduler instance across all Gunicorn modes.

* Fixed stale database connection handling in scheduled jobs:
  • Fresh connection acquired each run, properly released via try/finally
  • Eliminates "server closed the connection" errors.

* Definitive scheduler logic fix for all memory modes (ultra-light, optimized, performance):
  • Single-worker runs scheduler if GUNICORN\_WORKER\_ID is unset
  • Multi-worker: only worker 0 runs scheduler.

Impact

* Apprise and Email notifications are now stable, reliable, and production-ready
* No more duplicate or missed notifications across all memory modes
* Improved system efficiency and robustness
This commit is contained in:
sassanix
2025-08-24 12:34:40 -03:00
parent 59e858a905
commit 60239bd637
108 changed files with 34735 additions and 6283 deletions
+263 -2
View File
@@ -376,9 +376,22 @@
.search-container .import-btn,
.search-container #globalManageTagsBtn {
flex: 1 1 calc(33.333% - 5px) !important;
min-width: 90px !important;
min-width: 50px !important;
padding: 10px 8px !important;
font-size: 0.8rem !important;
font-size: 0.9rem !important;
}
/* Hide text on small screens for action buttons */
.search-container .export-btn span,
.search-container .import-btn span,
.search-container #globalManageTagsBtn span {
display: none;
}
.search-container .export-btn i,
.search-container .import-btn i,
.search-container #globalManageTagsBtn i {
margin-right: 0 !important;
}
}
@@ -700,4 +713,252 @@
.status-card .card-content .count {
font-size: 1.5rem !important;
}
}
@media (max-width: 768px) {
.warranties-list.list-view {
display: block !important;
}
.warranties-list.list-view .warranty-card {
display: block !important;
margin-bottom: 15px !important;
}
/* ===== MOBILE LIST VIEW OPTIMIZATIONS ===== */
/* Reduce padding and margins for mobile list view cards */
.list-view .warranty-card {
margin-bottom: 10px !important;
border-radius: 6px !important;
}
/* Optimize product name header for mobile */
.list-view .product-name-header {
padding: 10px 12px !important;
font-size: 1rem !important;
}
.list-view .product-name-header .warranty-title {
font-size: 1rem !important;
line-height: 1.3 !important;
white-space: normal !important; /* Allow wrapping on mobile */
overflow: visible !important;
text-overflow: clip !important;
max-width: calc(100% - 70px) !important; /* Make room for action buttons */
}
/* Optimize warranty content padding */
.list-view .warranty-content {
padding: 10px 12px !important;
flex-direction: column !important;
align-items: flex-start !important;
}
/* Optimize warranty info layout for mobile */
.list-view .warranty-info {
display: flex !important;
flex-direction: column !important;
gap: 8px !important;
width: 100% !important;
margin-bottom: 10px !important;
}
.list-view .warranty-info > div {
margin-right: 0 !important;
margin-bottom: 0 !important;
font-size: 0.9rem !important;
display: flex !important;
align-items: center !important;
}
.list-view .warranty-info > div i {
width: 18px !important;
margin-right: 6px !important;
font-size: 0.85rem !important;
flex-shrink: 0 !important;
}
.list-view .warranty-info > div span {
margin-left: 4px !important;
font-weight: 500 !important;
}
/* Optimize product photo for mobile list view */
.list-view .product-photo-thumbnail {
position: static !important;
margin-bottom: 10px !important;
text-align: center !important;
width: 100% !important;
}
.list-view .product-photo-thumbnail img {
width: 80px !important;
height: 80px !important;
border-radius: 6px !important;
object-fit: cover !important;
}
/* Optimize warranty status row */
.list-view .warranty-status-row {
padding: 8px 12px !important;
margin: 0 !important;
font-size: 0.9rem !important;
font-weight: 600 !important;
}
/* Optimize document links for mobile list view */
.list-view .document-links-row {
padding: 8px 12px !important;
gap: 8px !important;
flex-direction: row !important;
flex-wrap: wrap !important;
justify-content: flex-start !important;
}
.list-view .document-links-row a {
font-size: 0.85rem !important;
padding: 4px 8px !important;
margin-bottom: 4px !important;
white-space: nowrap !important;
}
/* Optimize tags row for mobile list view */
.list-view .warranty-card .tags-row {
padding: 8px 12px !important;
gap: 6px !important;
}
.list-view .tag {
font-size: 0.8rem !important;
padding: 3px 8px !important;
margin: 2px !important;
}
/* Serial numbers optimization for mobile list view */
.list-view .serial-numbers {
margin-top: 0 !important;
font-size: 0.9rem !important;
}
.list-view .serial-numbers ul {
margin: 5px 0 0 0 !important;
padding-left: 18px !important;
}
.list-view .serial-numbers li {
margin-bottom: 2px !important;
font-size: 0.85rem !important;
}
}
/* ===== MOBILE LIST VIEW - SMALLER SCREENS ===== */
@media (max-width: 480px) {
/* Further optimize for very small screens */
.list-view .warranty-card {
margin-bottom: 8px !important;
}
.list-view .product-name-header {
padding: 8px 10px !important;
}
.list-view .product-name-header .warranty-title {
font-size: 0.95rem !important;
max-width: calc(100% - 60px) !important;
}
.list-view .warranty-content {
padding: 8px 10px !important;
}
.list-view .warranty-info {
gap: 6px !important;
}
.list-view .warranty-info > div {
font-size: 0.85rem !important;
}
.list-view .warranty-info > div i {
width: 16px !important;
margin-right: 5px !important;
font-size: 0.8rem !important;
}
.list-view .product-photo-thumbnail img {
width: 60px !important;
height: 60px !important;
}
.list-view .warranty-status-row {
padding: 6px 10px !important;
font-size: 0.85rem !important;
}
.list-view .document-links-row {
padding: 6px 10px !important;
gap: 6px !important;
}
.list-view .document-links-row a {
font-size: 0.8rem !important;
padding: 3px 6px !important;
}
.list-view .warranty-card .tags-row {
padding: 6px 10px !important;
gap: 4px !important;
}
.list-view .tag {
font-size: 0.75rem !important;
padding: 2px 6px !important;
margin: 1px !important;
}
}
/* ===== MOBILE LIST VIEW - VERY SMALL SCREENS ===== */
@media (max-width: 360px) {
/* Ultra-compact for tiny screens */
.list-view .warranty-card {
margin-bottom: 6px !important;
}
.list-view .product-name-header {
padding: 6px 8px !important;
}
.list-view .product-name-header .warranty-title {
font-size: 0.9rem !important;
max-width: calc(100% - 55px) !important;
}
.list-view .warranty-content {
padding: 6px 8px !important;
}
.list-view .warranty-info > div {
font-size: 0.8rem !important;
}
.list-view .product-photo-thumbnail img {
width: 50px !important;
height: 50px !important;
}
.list-view .warranty-status-row {
padding: 5px 8px !important;
font-size: 0.8rem !important;
}
.list-view .document-links-row {
padding: 5px 8px !important;
gap: 4px !important;
}
.list-view .document-links-row a {
font-size: 0.75rem !important;
padding: 2px 5px !important;
}
}