Files
ApiCore/ApiCore-Backend/src/reminders/digest.step.ts
T
Nick SzaunigandClaude Opus 5.5 16cc557462
Backend Image / build-and-push (push) Successful in 4m26s
Frontend Image / build-and-push (push) Successful in 7m19s
Manifests / validate (push) Successful in 17s
feat: T4b/T4c wave 9 - phenology reports, autopilot A4-A10, honey ledger, Telegram delivery
- Phenology reports API with corrections and revokes; recompute per
  apiary via PhenologyRecomputeRequested, allowBackward for corrections;
  season changes are announced in the morning digest (changes since the
  previous digest, each once)
- Season autopilot A4-A10 with per-apiary sync (Apiary before Colony
  locks) and WinterCheckRecorded
- Honey batch ledger at runtime: initial amount, BOTTLING bookings,
  manual movements, one gram rounding, untracked bottlings never book
- Telegram delivery: planning, Berlin delivery times incl. DST, quiet
  hours, permission re-check and stale skip at send time, rate limits,
  cleanup of old deliveries
- ARCHITECTURE.md: assumptions 47-50 and updated sections 11.x

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-14 21:13:23 +02:00

32 lines
1.2 KiB
TypeScript

import { Injectable } from '@nestjs/common';
import type { DailyEvaluationStep } from '../jobs/daily-evaluation-steps';
import type { JobResult } from '../jobs/job';
import { DigestService, WINDOW_END_KEY } from './digest.service';
/**
* Step "digest", the last of the daily evaluation: the in-app morning
* digest of every user. Running it twice for one day writes nothing the
* second time (the key holds the day and the user): `digestsWritten` is 0
* on a same-day rerun.
*/
@Injectable()
export class DigestStep implements DailyEvaluationStep {
readonly name = 'digest';
constructor(private readonly digests: DigestService) {}
async run(today: string): Promise<JobResult> {
// The window of season changes ends here; the next run starts where
// this one stopped, so every change is reported once.
const until = new Date();
const digestsWritten = await this.digests.runFor(today, undefined, {
until,
});
// A run that wrote nothing (a same-day rerun, or no content) reported
// no change: the next run must still read the earlier window.
return digestsWritten === 0
? { digestsWritten }
: { digestsWritten, [WINDOW_END_KEY]: until.toISOString() };
}
}