Hide hidden live ids on the clear rate page

This commit is contained in:
Ethan O'Brien
2026-07-21 22:21:57 -05:00
parent 50ccecd821
commit b6cbfd0713
3 changed files with 24 additions and 0 deletions

View File

@@ -247,6 +247,10 @@ pub fn get_music_ids_for_user(user_id: i64) -> JsonValue {
ORDER BY music_id", params!(user_id)).unwrap_or(array![])
}
pub fn non_public_music_ids() -> JsonValue {
DATABASE.lock_and_select_all("SELECT music_id FROM songs WHERE visibility!='public' ORDER BY music_id", params!()).unwrap_or(array![])
}
// Which of these candidate ids no longer exist in the catalog. Only the custom
// range is ever considered, so official songs can't come back from this. A song
// that's merely private/shared still has its row - only genuinely deleted ids

View File

@@ -122,6 +122,10 @@ fn update_live_score(id: i64, uid: i64, score: i64) {
pub fn purge_live(live_id: i64) {
DATABASE.lock_and_exec("DELETE FROM lives WHERE live_id=?1", params!(live_id));
DATABASE.lock_and_exec("DELETE FROM scores WHERE live_id=?1", params!(live_id));
invalidate_cache();
}
pub fn invalidate_cache() {
crate::lock_onto_mutex!(CACHED_DATA).take();
crate::lock_onto_mutex!(CACHED_HTML_DATA).take();
}
@@ -184,9 +188,13 @@ fn get_pass_percent(failed: i64, pass: i64) -> String {
fn get_json() -> JsonValue {
let lives = DATABASE.lock_and_select_all("SELECT live_id FROM lives", params!()).unwrap();
let hidden = crate::router::custom_song::hidden_live_ids();
let mut rates = array![];
let mut ids = array![];
for id in lives.members() {
if hidden.contains(id.as_i64().unwrap()) {
continue;
}
let info = DATABASE.get_live_data(id.as_i64().unwrap());
if info.is_err() {
continue;
@@ -271,11 +279,15 @@ pub async fn ranking(req: HttpRequest, body: String) -> impl Responder {
fn get_html() -> JsonValue {
let lives = DATABASE.lock_and_select_all("SELECT live_id FROM lives", params!()).unwrap();
let hidden = crate::router::custom_song::hidden_live_ids();
let mut table = String::new();
for id in lives.members() {
let live_id = id.as_i64().unwrap();
if hidden.contains(live_id) {
continue;
}
let info = match DATABASE.get_live_data(live_id) {
Ok(i) => i,

View File

@@ -113,6 +113,13 @@ pub fn get_music_ids(uid: i64) -> JsonValue {
database::get_music_ids_for_user(uid)
}
pub fn hidden_live_ids() -> JsonValue {
if disabled() {
return array![];
}
database::non_public_music_ids()
}
fn song_path(music_id: i64, file: &str) -> String {
get_data_path(&format!("custom_songs/{}/{}", music_id, file))
}
@@ -882,6 +889,7 @@ async fn visibility(req: HttpRequest, body: String) -> HttpResponse {
database::set_downloads_disabled(music_id, body["downloads_disabled"].as_bool().unwrap_or(false));
}
database::bump_revision();
crate::router::clear_rate::invalidate_cache();
send_json(object!{
result: "OK"