Complete horoscope batches and atomic upserts
Complete horoscope batches and atomic upserts
For horoscopes, the product result is the expected sign set for one date and type, not one existing row. A single sign does not mean that the batch is ready.
Use the same completeness rule to read and write
Read with GROUP BY horoscope_date, horoscope_type, compare the sign set, and skip only when it exactly matches the expected set. Leave partial rows eligible for the next generation round. Before the database, reject duplicate, unsupported, mislabeled, or incomplete signs.
One batch, one transaction
Write a validated 12-row batch with executemany and one commit. If one row fails, roll back and report a count of zero. The UI can then distinguish partial work from complete work, and the scheduler retains a retry scope.
The rule applies to manual Admin generation and the automatic scheduler as well as LLM output. Last-write-wins may be the collision policy, but it must not turn an incomplete batch into a success.
Related course: Close partial failure, recovery, and platform boundaries