Add kcal display for songs on records/topscores.

This commit is contained in:
Jennifer Taylor 2025-10-01 01:08:22 +00:00
parent 13bebc392a
commit 40a95df161
4 changed files with 19 additions and 6 deletions

View File

@ -76,6 +76,7 @@ class DanceEvolutionFrontend(FrontendBase):
formatted_song["levels"] = levels
formatted_song["bpm_min"] = song.data.get_int("bpm_min")
formatted_song["bpm_max"] = song.data.get_int("bpm_max")
formatted_song["kcal"] = song.data.get_float("kcal")
return formatted_song
def merge_song(self, existing: Dict[str, Any], new: Song) -> Dict[str, Any]:

View File

@ -107,6 +107,7 @@ def viewtopscores(musicid: int) -> Response:
name = None
artist = None
genre = None
kcal = None
levels = [0, 0, 0, 0, 0]
for version in versions:
@ -119,6 +120,8 @@ def viewtopscores(musicid: int) -> Response:
artist = details.artist
if genre is None:
genre = details.genre
if kcal is None:
kcal = details.data.get_float("kcal")
if levels[chart] == 0:
levels[chart] = details.data.get_int("level")
@ -136,6 +139,7 @@ def viewtopscores(musicid: int) -> Response:
"artist": artist,
"genre": genre,
"levels": levels,
"kcal": kcal,
"players": top_scores["players"],
"topscores": top_scores["topscores"],
},

View File

@ -110,11 +110,19 @@ var network_records = createReactClass({
);
},
renderLevel: function(songid, chart) {
if (this.state.songs[songid].levels[chart] == 0) {
renderLevel: function(songid) {
if (this.state.songs[songid].levels[0] == 0) {
return <span className="level">--</span>;
} else {
return <span className="level">{this.state.songs[songid].levels[chart]}</span>;
return <span className="level">{this.state.songs[songid].levels[0]}</span>;
}
},
renderKcal: function(songid) {
if (this.state.songs[songid].kcal <= 0.0) {
return <span className="kcal">--</span>;
} else {
return <span className="kcal">{this.state.songs[songid].kcal}</span>;
}
},
@ -180,7 +188,7 @@ var network_records = createReactClass({
</a>
</div>
<div className="songlevels">
Level {this.renderLevel(songid, 0)}
level {this.renderLevel(songid)} / {this.renderKcal(songid)} kcal
</div>
</td>
<td className={levels[0] > 0 ? "" : "nochart"}>
@ -410,7 +418,7 @@ var network_records = createReactClass({
</a>
</div>
<div className="songlevels">
Level {this.renderLevel(songid, 0)}
level {this.renderLevel(songid)} / {this.renderKcal(songid)} kcal
</div>
{ showplays ? <div className="songplays">#{index + 1} - {plays}{plays == 1 ? ' play' : ' plays'}</div> : null }
</td>

View File

@ -71,7 +71,7 @@ var top_scores = createReactClass({
<div className="songname">{window.name}</div>
<div className="songartist">{window.artist}</div>
<div className="songgenre">{window.genre}</div>
<div className="songlevels">Level {window.levels[chart]}</div>
<div className="songlevels">level {window.levels[chart]} / {window.kcal} kcal</div>
</div>
<div className="section">
{valid_charts.map(function(chart) {