show only completed matches in match log

This commit is contained in:
Ilion Beyst 2022-08-29 22:06:21 +02:00
parent c6c484daf3
commit e8e353192c

View file

@ -141,6 +141,7 @@ fn fetch_full_match_data(
pub fn list_matches(amount: i64, conn: &PgConnection) -> QueryResult<Vec<FullMatchData>> { pub fn list_matches(amount: i64, conn: &PgConnection) -> QueryResult<Vec<FullMatchData>> {
conn.transaction(|| { conn.transaction(|| {
let matches = matches::table let matches = matches::table
.filter(matches::state.eq(MatchState::Finished))
.order_by(matches::created_at.desc()) .order_by(matches::created_at.desc())
.limit(amount) .limit(amount)
.get_results::<MatchBase>(conn)?; .get_results::<MatchBase>(conn)?;
@ -158,6 +159,7 @@ pub fn list_public_matches(
conn.transaction(|| { conn.transaction(|| {
// TODO: how can this common logic be abstracted? // TODO: how can this common logic be abstracted?
let query = matches::table let query = matches::table
.filter(matches::state.eq(MatchState::Finished))
.filter(matches::is_public.eq(true)) .filter(matches::is_public.eq(true))
.into_boxed(); .into_boxed();
@ -175,6 +177,7 @@ pub fn list_bot_matches(
conn: &PgConnection, conn: &PgConnection,
) -> QueryResult<Vec<FullMatchData>> { ) -> QueryResult<Vec<FullMatchData>> {
let query = matches::table let query = matches::table
.filter(matches::state.eq(MatchState::Finished))
.filter(matches::is_public.eq(true)) .filter(matches::is_public.eq(true))
.order_by(matches::created_at.desc()) .order_by(matches::created_at.desc())
.inner_join(match_players::table) .inner_join(match_players::table)