aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'planetwars-server/src/db')
-rw-r--r--planetwars-server/src/db/bots.rs8
-rw-r--r--planetwars-server/src/db/matches.rs12
2 files changed, 10 insertions, 10 deletions
diff --git a/planetwars-server/src/db/bots.rs b/planetwars-server/src/db/bots.rs
index 964deaa..53c11b1 100644
--- a/planetwars-server/src/db/bots.rs
+++ b/planetwars-server/src/db/bots.rs
@@ -51,7 +51,7 @@ pub struct NewCodeBundle<'a> {
}
#[derive(Queryable, Serialize, Deserialize, Debug)]
-pub struct CodeBundle {
+pub struct BotVersion {
pub id: i32,
pub bot_id: Option<i32>,
pub code_bundle_path: Option<String>,
@@ -62,19 +62,19 @@ pub struct CodeBundle {
pub fn create_code_bundle(
new_code_bundle: &NewCodeBundle,
conn: &PgConnection,
-) -> QueryResult<CodeBundle> {
+) -> QueryResult<BotVersion> {
diesel::insert_into(bot_versions::table)
.values(new_code_bundle)
.get_result(conn)
}
-pub fn find_bot_code_bundles(bot_id: i32, conn: &PgConnection) -> QueryResult<Vec<CodeBundle>> {
+pub fn find_bot_versions(bot_id: i32, conn: &PgConnection) -> QueryResult<Vec<BotVersion>> {
bot_versions::table
.filter(bot_versions::bot_id.eq(bot_id))
.get_results(conn)
}
-pub fn active_code_bundle(bot_id: i32, conn: &PgConnection) -> QueryResult<CodeBundle> {
+pub fn active_bot_version(bot_id: i32, conn: &PgConnection) -> QueryResult<BotVersion> {
bot_versions::table
.filter(bot_versions::bot_id.eq(bot_id))
.order(bot_versions::created_at.desc())
diff --git a/planetwars-server/src/db/matches.rs b/planetwars-server/src/db/matches.rs
index d9d893c..6590a37 100644
--- a/planetwars-server/src/db/matches.rs
+++ b/planetwars-server/src/db/matches.rs
@@ -8,7 +8,7 @@ use diesel::{Connection, GroupedBy, PgConnection, QueryResult};
use crate::schema::{bot_versions, bots, match_players, matches};
-use super::bots::{Bot, CodeBundle};
+use super::bots::{Bot, BotVersion};
#[derive(Insertable)]
#[table_name = "matches"]
@@ -25,7 +25,7 @@ pub struct NewMatchPlayer {
/// player id within the match
pub player_id: i32,
/// id of the bot behind this player
- pub code_bundle_id: Option<i32>,
+ pub bot_version_id: Option<i32>,
}
#[derive(Queryable, Identifiable)]
@@ -67,7 +67,7 @@ pub fn create_match(
.map(|(num, player_data)| NewMatchPlayer {
match_id: match_base.id,
player_id: num as i32,
- code_bundle_id: player_data.code_bundle_id,
+ bot_version_id: player_data.code_bundle_id,
})
.collect::<Vec<_>>();
@@ -94,7 +94,7 @@ pub fn list_matches(conn: &PgConnection) -> QueryResult<Vec<FullMatchData>> {
let match_players = MatchPlayer::belonging_to(&matches)
.left_join(
bot_versions::table
- .on(match_players::code_bundle_id.eq(bot_versions::id.nullable())),
+ .on(match_players::bot_version_id.eq(bot_versions::id.nullable())),
)
.left_join(bots::table.on(bot_versions::bot_id.eq(bots::id.nullable())))
.load::<FullMatchPlayerData>(conn)?
@@ -123,7 +123,7 @@ pub struct FullMatchData {
// #[primary_key(base.match_id, base::player_id)]
pub struct FullMatchPlayerData {
pub base: MatchPlayer,
- pub code_bundle: Option<CodeBundle>,
+ pub bot_version: Option<BotVersion>,
pub bot: Option<Bot>,
}
@@ -147,7 +147,7 @@ pub fn find_match(id: i32, conn: &PgConnection) -> QueryResult<FullMatchData> {
let match_players = MatchPlayer::belonging_to(&match_base)
.left_join(
bot_versions::table
- .on(match_players::code_bundle_id.eq(bot_versions::id.nullable())),
+ .on(match_players::bot_version_id.eq(bot_versions::id.nullable())),
)
.left_join(bots::table.on(bot_versions::bot_id.eq(bots::id.nullable())))
.load::<FullMatchPlayerData>(conn)?;