Two teams try and fill in any horizontal, vertical, or diagonal line on a bingo board by playing maps on osu! osu.bingo
osu
at microservice 41 lines 1.0 kB view raw
1use chrono::{DateTime, Utc}; 2use juniper::{FieldError, FieldResult, graphql_object}; 3use serde::{Deserialize, Serialize}; 4 5use crate::{database::DataContext, schema::BingoGame}; 6 7#[derive(sqlx::FromRow, Deserialize, Serialize)] 8pub struct TimeEvent { 9 id: String, 10 time: DateTime<Utc>, 11 action: String, 12 fulfilled: bool, 13 14 game_id: String, 15} 16 17#[graphql_object(description = "Represents an event that is scheduled to happen at a certain time", Context = DataContext)] 18impl TimeEvent { 19 fn id(&self) -> &str { 20 self.id.as_ref() 21 } 22 fn time(&self) -> &DateTime<Utc> { 23 &self.time 24 } 25 fn action(&self) -> &str { 26 self.action.as_ref() 27 } 28 fn fulfilled(&self) -> bool { 29 self.fulfilled 30 } 31 32 /// The game this square is associated with 33 pub async fn game(&self, context: &DataContext) -> FieldResult<BingoGame> { 34 context 35 .acquire() 36 .await 37 .get_game_by_id(&self.game_id) 38 .await 39 .map_err(FieldError::from) 40 } 41}