/** Seven days from activation; edits and new variants never reset this window.
 * Keep the same rule in the admin's lib/automaticNewBadge.ts.
 */
export const recentPerfumeSql = `(p.type = 'perfume'
  AND p.is_active = 1
  AND p.activated_at <= NOW()
  AND p.activated_at > DATE_SUB(NOW(), INTERVAL 7 DAY))`;

/** NOVINKA is computed, all other badges retain their manual assignments. */
export const productBadgeJoinSql = `LEFT JOIN badges pb ON
  (pb.id = pbm.b_id AND UPPER(TRIM(pb.name)) <> 'NOVINKA')
  OR (UPPER(TRIM(pb.name)) = 'NOVINKA' AND ${recentPerfumeSql})`;
