Change result end point to output artist info
This commit is contained in:
+17
-4
@@ -141,18 +141,30 @@ CREATE TABLE CountryCodes (
|
||||
CREATE VIEW ReviewSummaryGlobal AS
|
||||
SELECT
|
||||
song_id,
|
||||
cc.name_fi AS country_fi,
|
||||
cc.name_sv AS country_sv,
|
||||
s.artist,
|
||||
s.title,
|
||||
COUNT(*) AS total_reviews,
|
||||
AVG(score_song) AS avg_score_song,
|
||||
AVG(score_show) AS avg_score_show,
|
||||
AVG(score_costume) AS avg_score_costume,
|
||||
AVG((score_song + score_show + score_costume)/3) AS avg_total_score
|
||||
FROM Review
|
||||
GROUP BY song_id;
|
||||
FROM Review r
|
||||
JOIN Song s ON r.song_id = s.id
|
||||
JOIN CountryCodes cc ON s.country = cc.code
|
||||
GROUP BY song_id, cc.name_fi, cc.name_sv, s.artist, s.title
|
||||
ORDER BY avg_total_score DESC;
|
||||
|
||||
CREATE VIEW ReviewSummaryByTeam AS
|
||||
SELECT
|
||||
r.song_id,
|
||||
cc.name_fi AS country_fi,
|
||||
cc.name_sv AS country_sv,
|
||||
s.artist,
|
||||
s.title,
|
||||
u.team_id,
|
||||
COUNT(*) AS total_reviews,
|
||||
AVG(r.score_song) AS avg_score_song,
|
||||
AVG(r.score_show) AS avg_score_show,
|
||||
AVG(r.score_costume) AS avg_score_costume,
|
||||
@@ -160,8 +172,9 @@ SELECT
|
||||
FROM Review r
|
||||
JOIN "User" u ON r.user_id = u.id
|
||||
JOIN Song s ON r.song_id = s.id
|
||||
GROUP BY r.song_id, u.team_id
|
||||
ORDER BY r.song_id, u.team_id;
|
||||
JOIN CountryCodes cc ON s.country = cc.code
|
||||
GROUP BY r.song_id, u.team_id, cc.name_fi, cc.name_sv, s.artist, s.title
|
||||
ORDER BY avg_total_score DESC;
|
||||
|
||||
-- Insert country codes data
|
||||
INSERT INTO CountryCodes (code, name_en, name_fi, name_sv) VALUES ('ALB', 'Albania', 'Albania', 'Albanien');
|
||||
|
||||
@@ -3,6 +3,14 @@ from pydantic import BaseModel, Field
|
||||
|
||||
class Result(BaseModel):
|
||||
song_id: int = Field(description="ID of the song", examples=[1])
|
||||
country_fi: str = Field(
|
||||
description="Country of the song in Finnish", examples=["Suomi"]
|
||||
)
|
||||
country_sv: str = Field(
|
||||
description="Country of the song in Swedish", examples=["Sverige"]
|
||||
)
|
||||
artist: str = Field(description="Artist of the song", examples=["Käärijä"])
|
||||
title: str = Field(description="Title of the song", examples=["Cha cha cha"])
|
||||
total_reviews: int = Field(0, description="Total number of reviews", examples=[10])
|
||||
avg_score_song: float = Field(
|
||||
description="Average score for song quality", examples=[85.5]
|
||||
|
||||
Reference in New Issue
Block a user