Two teams try and fill in any horizontal, vertical, or diagonal line on a bingo board by playing maps on osu!
osu.bingo
osu
1use juniper::{FieldError, FieldResult, graphql_object};
2use serde::{Deserialize, Serialize};
3
4use crate::{
5 database::DataContext,
6 schema::{Map, Mappool},
7};
8
9#[derive(sqlx::FromRow, Deserialize, Serialize)]
10pub struct MapInPool {
11 id: String,
12 pool_id: String,
13 map_id: i32,
14
15 required_mods: Option<String>,
16}
17
18#[graphql_object(description = "Represents a map being a part of some mappool", Context = DataContext)]
19impl MapInPool {
20 /// A unique identifier for mapinpool objects
21 fn id(&self) -> &str {
22 self.id.as_ref()
23 }
24
25 /// Mods that are forced
26 fn required_mods(&self) -> Option<&String> {
27 self.required_mods.as_ref()
28 }
29
30 /// The map associated
31 pub async fn map(&self, context: &DataContext) -> FieldResult<Map> {
32 context
33 .acquire()
34 .await
35 .get_map_by_id(self.map_id)
36 .await
37 .map_err(FieldError::from)
38 }
39
40 /// The pool associated
41 pub async fn pool(&self, context: &DataContext) -> FieldResult<Mappool> {
42 context
43 .acquire()
44 .await
45 .get_mappool_by_id(&self.pool_id)
46 .await
47 .map_err(FieldError::from)
48 }
49}