mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-08-26 15:02:18 +08:00
Hide hidden live ids on the clear rate page
This commit is contained in:
@@ -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![])
|
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
|
// 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
|
// 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
|
// that's merely private/shared still has its row - only genuinely deleted ids
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ fn update_live_score(id: i64, uid: i64, score: i64) {
|
|||||||
pub fn purge_live(live_id: 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 lives WHERE live_id=?1", params!(live_id));
|
||||||
DATABASE.lock_and_exec("DELETE FROM scores 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_DATA).take();
|
||||||
crate::lock_onto_mutex!(CACHED_HTML_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 {
|
fn get_json() -> JsonValue {
|
||||||
let lives = DATABASE.lock_and_select_all("SELECT live_id FROM lives", params!()).unwrap();
|
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 rates = array![];
|
||||||
let mut ids = array![];
|
let mut ids = array![];
|
||||||
for id in lives.members() {
|
for id in lives.members() {
|
||||||
|
if hidden.contains(id.as_i64().unwrap()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let info = DATABASE.get_live_data(id.as_i64().unwrap());
|
let info = DATABASE.get_live_data(id.as_i64().unwrap());
|
||||||
if info.is_err() {
|
if info.is_err() {
|
||||||
continue;
|
continue;
|
||||||
@@ -271,11 +279,15 @@ pub async fn ranking(req: HttpRequest, body: String) -> impl Responder {
|
|||||||
|
|
||||||
fn get_html() -> JsonValue {
|
fn get_html() -> JsonValue {
|
||||||
let lives = DATABASE.lock_and_select_all("SELECT live_id FROM lives", params!()).unwrap();
|
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();
|
let mut table = String::new();
|
||||||
|
|
||||||
for id in lives.members() {
|
for id in lives.members() {
|
||||||
let live_id = id.as_i64().unwrap();
|
let live_id = id.as_i64().unwrap();
|
||||||
|
if hidden.contains(live_id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let info = match DATABASE.get_live_data(live_id) {
|
let info = match DATABASE.get_live_data(live_id) {
|
||||||
Ok(i) => i,
|
Ok(i) => i,
|
||||||
|
|||||||
@@ -113,6 +113,13 @@ pub fn get_music_ids(uid: i64) -> JsonValue {
|
|||||||
database::get_music_ids_for_user(uid)
|
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 {
|
fn song_path(music_id: i64, file: &str) -> String {
|
||||||
get_data_path(&format!("custom_songs/{}/{}", music_id, file))
|
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::set_downloads_disabled(music_id, body["downloads_disabled"].as_bool().unwrap_or(false));
|
||||||
}
|
}
|
||||||
database::bump_revision();
|
database::bump_revision();
|
||||||
|
crate::router::clear_rate::invalidate_cache();
|
||||||
|
|
||||||
send_json(object!{
|
send_json(object!{
|
||||||
result: "OK"
|
result: "OK"
|
||||||
|
|||||||
Reference in New Issue
Block a user