forked from mirrors/homebox
feat: use notifiers on schedule (#362)
* fix potential memory leak with time.After * add new background service to manage scheduled notifications * update docs * remove old js reference * closes #278 * tidy
This commit is contained in:
parent
975e636fb6
commit
840d220d4f
16 changed files with 201 additions and 52 deletions
|
@ -84,6 +84,27 @@ func mapMaintenanceEntry(entry *ent.MaintenanceEntry) MaintenanceEntry {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *MaintenanceEntryRepository) GetScheduled(ctx context.Context, GID uuid.UUID, dt types.Date) ([]MaintenanceEntry, error) {
|
||||
entries, err := r.db.MaintenanceEntry.Query().
|
||||
Where(
|
||||
maintenanceentry.HasItemWith(
|
||||
item.HasGroupWith(group.ID(GID)),
|
||||
),
|
||||
maintenanceentry.ScheduledDate(dt.Time()),
|
||||
maintenanceentry.Or(
|
||||
maintenanceentry.DateIsNil(),
|
||||
maintenanceentry.DateEQ(time.Time{}),
|
||||
),
|
||||
).
|
||||
All(ctx)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mapEachMaintenanceEntry(entries), nil
|
||||
}
|
||||
|
||||
func (r *MaintenanceEntryRepository) Create(ctx context.Context, itemID uuid.UUID, input MaintenanceEntryCreate) (MaintenanceEntry, error) {
|
||||
item, err := r.db.MaintenanceEntry.Create().
|
||||
SetItemID(itemID).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue