+
Moyenne équipe
diff --git a/src/components/weather/WeatherCard.tsx b/src/components/weather/WeatherCard.tsx
index f17585e..ffa6b1e 100644
--- a/src/components/weather/WeatherCard.tsx
+++ b/src/components/weather/WeatherCard.tsx
@@ -48,12 +48,45 @@ function EvolutionIndicator({
if (direction === null) return null;
if (direction === 'up') {
- return ↑;
+ return (
+
+ ↑
+
+ );
}
if (direction === 'down') {
- return ↓;
+ return (
+
+ ↓
+
+ );
}
- return →;
+ return (
+
+ →
+
+ );
}
export function WeatherCard({ sessionId, currentUserId, entry, canEdit, previousEntry }: WeatherCardProps) {
diff --git a/src/services/weather.ts b/src/services/weather.ts
index c379eaf..69b087f 100644
--- a/src/services/weather.ts
+++ b/src/services/weather.ts
@@ -203,17 +203,25 @@ export async function getPreviousWeatherEntriesForUsers(
sessionId: { not: excludeSessionId },
session: { date: { lt: sessionDate } },
},
- orderBy: [{ userId: 'asc' }, { session: { date: 'desc' } }],
select: {
userId: true,
performanceEmoji: true,
moralEmoji: true,
fluxEmoji: true,
valueCreationEmoji: true,
+ session: { select: { date: true } },
},
});
- // Keep only the most recent entry per user (first occurrence since ordered by date desc)
+ // Sort by session.date desc (Prisma orderBy on relation is unreliable with SQLite)
+ entries.sort((a, b) => {
+ const dateA = a.session.date.getTime();
+ const dateB = b.session.date.getTime();
+ if (dateB !== dateA) return dateB - dateA; // most recent first
+ return a.userId.localeCompare(b.userId);
+ });
+
+ // For each user, use the most recent previous value PER AXIS (fallback if latest session has null)
const map = new Map<
string,
{
@@ -224,14 +232,19 @@ export async function getPreviousWeatherEntriesForUsers(
}
>();
for (const entry of entries) {
- if (!map.has(entry.userId)) {
- map.set(entry.userId, {
- performanceEmoji: entry.performanceEmoji,
- moralEmoji: entry.moralEmoji,
- fluxEmoji: entry.fluxEmoji,
- valueCreationEmoji: entry.valueCreationEmoji,
- });
- }
+ const existing = map.get(entry.userId);
+ const base = existing ?? {
+ performanceEmoji: null as string | null,
+ moralEmoji: null as string | null,
+ fluxEmoji: null as string | null,
+ valueCreationEmoji: null as string | null,
+ };
+ if (!existing) map.set(entry.userId, base);
+ if (base.performanceEmoji == null && entry.performanceEmoji != null) base.performanceEmoji = entry.performanceEmoji;
+ if (base.moralEmoji == null && entry.moralEmoji != null) base.moralEmoji = entry.moralEmoji;
+ if (base.fluxEmoji == null && entry.fluxEmoji != null) base.fluxEmoji = entry.fluxEmoji;
+ if (base.valueCreationEmoji == null && entry.valueCreationEmoji != null)
+ base.valueCreationEmoji = entry.valueCreationEmoji;
}
return map;
}