fix: improve rating UI label and notification context

This commit is contained in:
Hördle Bot
2025-11-23 10:42:20 +01:00
parent 4d3032df36
commit f13a719d0e
2 changed files with 25 additions and 15 deletions

View File

@@ -34,7 +34,7 @@ export async function sendGotifyNotification(attempts: number, status: 'won' | '
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export async function submitRating(songId: number, rating: number, genre?: string | null) {
export async function submitRating(songId: number, rating: number, genre?: string | null, isSpecial?: boolean, puzzleNumber?: number) {
try {
const song = await prisma.song.findUnique({ where: { id: songId } });
if (!song) throw new Error('Song not found');
@@ -51,9 +51,17 @@ export async function submitRating(songId: number, rating: number, genre?: strin
});
// Send Gotify notification for the rating
const genreText = genre ? `[${genre}] ` : '';
let context = 'Global Daily Puzzle';
if (genre) {
context = isSpecial ? `Special Puzzle "${genre}"` : `Genre Puzzle "${genre}"`;
}
if (puzzleNumber) {
context += ` #${puzzleNumber}`;
}
const title = `Hördle Rating: ${rating} Stars`;
const message = `Song "${song.title}" by ${song.artist} ${genreText}received a ${rating}-star rating. (Avg: ${newAverageRating.toFixed(2)}, Count: ${newRatingCount})`;
// Do not show song title/artist to avoid spoilers
const message = `${context} received a ${rating}-star rating.\nNew Average: ${newAverageRating.toFixed(2)} (${newRatingCount} ratings)`;
await fetch(`${GOTIFY_URL}/message?token=${GOTIFY_APP_TOKEN}`, {
method: 'POST',