Skip to content

Commit 863bf62

Browse files
Fix updated field including deleted versions (#3643)
* Fix `updated` field including deleted versions Four years ago, I created issue modrinth/labrinth#200. Today, while it adorns a different name (#2766), the issue remains the same. In celebration of Modrinth's oldest bug report, here is a fix. Instead of having a separate `updated` field, it simply pulls the publish date of the most recent version. This should also allow the `updated` column on the `mods` table to be dropped at a later date, but I would rather get confirmation that it works before we go ahead with that. Fixes #2766 * Update apps/labrinth/src/database/models/project_item.rs Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com> Signed-off-by: Emma Alexia <wafflecoffee7@gmail.com> --------- Signed-off-by: Emma Alexia <wafflecoffee7@gmail.com> Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com>
1 parent 9a6390b commit 863bf62

File tree

2 files changed

+23
-31
lines changed

2 files changed

+23
-31
lines changed

apps/labrinth/.sqlx/query-c7c400d74c478b4194f478f6d732a92c0b9a72e1cb6147009018b2712398c24f.json renamed to apps/labrinth/.sqlx/query-5f75c0c48083de27f853ee877aac070567fd2ed2be4a9a038821b790dd7cb763.json

Lines changed: 18 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/src/database/models/project_item.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ impl Project {
759759
"
760760
SELECT m.id id, m.name name, m.summary summary, m.downloads downloads, m.follows follows,
761761
m.icon_url icon_url, m.raw_icon_url raw_icon_url, m.description description, m.published published,
762-
m.updated updated, m.approved approved, m.queued, m.status status, m.requested_status requested_status,
762+
m.approved approved, m.queued, m.status status, m.requested_status requested_status,
763763
m.license_url license_url,
764764
m.team_id team_id, m.organization_id organization_id, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,
765765
m.webhook_sent, m.color,
@@ -786,7 +786,9 @@ impl Project {
786786
games,
787787
loader_loader_field_ids,
788788
} = loaders_ptypes_games.remove(&project_id).map(|x|x.1).unwrap_or_default();
789+
// Each version is a tuple of (VersionId, DateTime<Utc>)
789790
let mut versions = versions.remove(&project_id).map(|x| x.1).unwrap_or_default();
791+
versions.sort_by(|a, b| a.1.cmp(&b.1));
790792
let mut gallery = mods_gallery.remove(&project_id).map(|x| x.1).unwrap_or_default();
791793
let urls = links.remove(&project_id).map(|x| x.1).unwrap_or_default();
792794
let version_fields = version_fields.remove(&project_id).map(|x| x.1).unwrap_or_default();
@@ -806,7 +808,7 @@ impl Project {
806808
icon_url: m.icon_url.clone(),
807809
raw_icon_url: m.raw_icon_url.clone(),
808810
published: m.published,
809-
updated: m.updated,
811+
updated: versions.iter().map(|x| x.1).next_back().unwrap_or(m.published),
810812
license_url: m.license_url.clone(),
811813
status: ProjectStatus::from_string(
812814
&m.status,
@@ -833,11 +835,7 @@ impl Project {
833835
additional_categories: m.additional_categories.unwrap_or_default(),
834836
project_types,
835837
games,
836-
versions: {
837-
// Each version is a tuple of (VersionId, DateTime<Utc>)
838-
versions.sort_by(|a, b| a.1.cmp(&b.1));
839-
versions.into_iter().map(|x| x.0).collect()
840-
},
838+
versions: versions.into_iter().map(|x| x.0).collect(),
841839
gallery_items: {
842840
gallery.sort_by(|a, b| a.ordering.cmp(&b.ordering));
843841
gallery

0 commit comments

Comments
 (0)