Skip to content

Commit

Permalink
fix(competitions): deduce last edition using the start date instead o…
Browse files Browse the repository at this point in the history
…f the given order
  • Loading branch information
davidsandoz committed May 25, 2024
1 parent 821f37f commit c9bb464
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions models/competition.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default class Competition {
return null;
}

// FIXME: This is a naive selection of the last edition. It might not work, i.e. when adding older editions.
return this.editions[this.editions.length - 1];
return this.editions.reduce((lastEdition, edition) => {
return edition.season.date_start > lastEdition.season.date_start ? edition : lastEdition;
});
}
}
2 changes: 1 addition & 1 deletion plugins/cms-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ const cmsService: Plugin = (context, inject) => {
editions: [
'leverade_id',
{
season: ['id', 'name', 'slug', 'leverade_id'],
season: ['id', 'name', 'slug', 'leverade_id', 'date_start'],
},
],
},
Expand Down

0 comments on commit c9bb464

Please sign in to comment.