From 73a8c302e9c48b173f9c12983b64abf7ac9925b9 Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Tue, 25 Jan 2022 13:00:32 -0700 Subject: [PATCH] Fix duplicate dates (#282) --- src/routes/projects.rs | 2 +- src/scheduler.rs | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/routes/projects.rs b/src/routes/projects.rs index b99dc2d14..cffb76fa5 100644 --- a/src/routes/projects.rs +++ b/src/routes/projects.rs @@ -1461,7 +1461,7 @@ pub async fn delete_from_index( let indexes: Vec = client.get_indexes().await?; for index in indexes { - index.delete_document(format!("local-{}", id)).await?; + index.delete_document(format!("{}", id)).await?; } Ok(()) diff --git a/src/scheduler.rs b/src/scheduler.rs index 1f13a7014..ced311271 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -116,6 +116,37 @@ async fn update_versions(pool: &sqlx::Pool) -> Result<(), Versio ("3D Shareware v1.34", "3D-Shareware-v1.34"), ]; + lazy_static::lazy_static! { + /// Mojank for some reason has versions released at the same DateTime. This hardcodes them to fix this, + /// as most of our ordering logic is with DateTime + static ref HALL_OF_SHAME_2: [(&'static str, chrono::DateTime); 4] = [ + ( + "1.4.5", + chrono::DateTime::parse_from_rfc3339("2012-12-19T22:00:00+00:00") + .unwrap() + .into(), + ), + ( + "1.4.6", + chrono::DateTime::parse_from_rfc3339("2012-12-19T22:00:01+00:00") + .unwrap() + .into(), + ), + ( + "1.6.3", + chrono::DateTime::parse_from_rfc3339("2013-09-13T10:54:41+00:00") + .unwrap() + .into(), + ), + ( + "13w37b", + chrono::DateTime::parse_from_rfc3339("2013-09-13T10:54:42+00:00") + .unwrap() + .into(), + ), + ]; + } + for version in input.versions.into_iter() { let mut name = version.id; if !name @@ -143,7 +174,15 @@ async fn update_versions(pool: &sqlx::Pool) -> Result<(), Versio crate::database::models::categories::GameVersion::builder() .version(&name)? .version_type(type_)? - .created(&version.release_time) + .created( + if let Some((_, alternate)) = + HALL_OF_SHAME_2.iter().find(|(version, _)| name == *version) + { + alternate + } else { + &version.release_time + }, + ) .insert(pool) .await?; }