fix faction IDs

This commit is contained in:
41666 2023-03-05 11:34:16 -05:00
parent 679b49ff88
commit bca70e2d5b
6 changed files with 29 additions and 13 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
/target /target
.DS_Store
*/.DS_Store

View file

@ -1,4 +1,7 @@
use crate::utils::{Filters, IdOrNameBy}; use crate::{
factions::{NC, TR, VS},
utils::{Filters, IdOrNameBy},
};
use async_graphql::{Context, Object}; use async_graphql::{Context, Object};
use sqlx::{Pool, Postgres, Row}; use sqlx::{Pool, Postgres, Row};
@ -39,7 +42,7 @@ impl Class {
self.fetch( self.fetch(
ctx, ctx,
Filters { Filters {
faction: Some(IdOrNameBy::Id(1)), faction: Some(IdOrNameBy::Id(NC)),
..self.filters.clone() ..self.filters.clone()
}, },
) )
@ -49,7 +52,7 @@ impl Class {
self.fetch( self.fetch(
ctx, ctx,
Filters { Filters {
faction: Some(IdOrNameBy::Id(2)), faction: Some(IdOrNameBy::Id(TR)),
..self.filters.clone() ..self.filters.clone()
}, },
) )
@ -59,7 +62,7 @@ impl Class {
self.fetch( self.fetch(
ctx, ctx,
Filters { Filters {
faction: Some(IdOrNameBy::Id(3)), faction: Some(IdOrNameBy::Id(VS)),
..self.filters.clone() ..self.filters.clone()
}, },
) )

View file

@ -0,0 +1,4 @@
pub const VS: i32 = 1;
pub const NC: i32 = 2;
pub const TR: i32 = 3;
pub const NSO: i32 = 4;

View file

@ -1,5 +1,6 @@
mod analytics; mod analytics;
mod classes; mod classes;
mod factions;
mod health; mod health;
mod population; mod population;
mod query; mod query;

View file

@ -1,4 +1,7 @@
use crate::utils::Filters; use crate::{
factions::{NC, NSO, TR, VS},
utils::Filters,
};
use async_graphql::{Context, Object}; use async_graphql::{Context, Object};
use sqlx::{Pool, Postgres, Row}; use sqlx::{Pool, Postgres, Row};
@ -58,16 +61,16 @@ impl Population {
query query
} }
async fn nc<'ctx>(&self, ctx: &Context<'ctx>) -> i64 { async fn nc<'ctx>(&self, ctx: &Context<'ctx>) -> i64 {
self.by_faction(ctx, 1).await self.by_faction(ctx, NC).await
} }
async fn vs<'ctx>(&self, ctx: &Context<'ctx>) -> i64 { async fn vs<'ctx>(&self, ctx: &Context<'ctx>) -> i64 {
self.by_faction(ctx, 2).await self.by_faction(ctx, VS).await
} }
async fn tr<'ctx>(&self, ctx: &Context<'ctx>) -> i64 { async fn tr<'ctx>(&self, ctx: &Context<'ctx>) -> i64 {
self.by_faction(ctx, 3).await self.by_faction(ctx, TR).await
} }
async fn ns<'ctx>(&self, ctx: &Context<'ctx>) -> i64 { async fn ns<'ctx>(&self, ctx: &Context<'ctx>) -> i64 {
self.by_faction(ctx, 4).await self.by_faction(ctx, NSO).await
} }
} }

View file

@ -1,4 +1,7 @@
use crate::utils::{Filters, IdOrNameBy}; use crate::{
factions::{NC, TR, VS},
utils::{Filters, IdOrNameBy},
};
use async_graphql::{Context, Object}; use async_graphql::{Context, Object};
use sqlx::{Pool, Postgres, Row}; use sqlx::{Pool, Postgres, Row};
@ -39,7 +42,7 @@ impl Vehicle {
self.fetch( self.fetch(
ctx, ctx,
Filters { Filters {
faction: Some(IdOrNameBy::Id(1)), faction: Some(IdOrNameBy::Id(NC)),
..self.filters.clone() ..self.filters.clone()
}, },
) )
@ -49,7 +52,7 @@ impl Vehicle {
self.fetch( self.fetch(
ctx, ctx,
Filters { Filters {
faction: Some(IdOrNameBy::Id(2)), faction: Some(IdOrNameBy::Id(TR)),
..self.filters.clone() ..self.filters.clone()
}, },
) )
@ -59,7 +62,7 @@ impl Vehicle {
self.fetch( self.fetch(
ctx, ctx,
Filters { Filters {
faction: Some(IdOrNameBy::Id(3)), faction: Some(IdOrNameBy::Id(VS)),
..self.filters.clone() ..self.filters.clone()
}, },
) )