aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-02-27 22:57:06 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2022-02-27 22:57:06 +0100
commitedb3ead976cd51ab6d627fe6b36bb9f0be8a17d3 (patch)
tree87c9e07d59c45e4c4c03fdb0fa7de83ac5449075 /planetwars-server/src/db
parentda7164317681aeca442ccef6ed0a74ad1952f0bf (diff)
downloadplanetwars.dev-edb3ead976cd51ab6d627fe6b36bb9f0be8a17d3.tar.xz
planetwars.dev-edb3ead976cd51ab6d627fe6b36bb9f0be8a17d3.zip
retrieve opponent from bots database
Diffstat (limited to 'planetwars-server/src/db')
-rw-r--r--planetwars-server/src/db/bots.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/planetwars-server/src/db/bots.rs b/planetwars-server/src/db/bots.rs
index baabd5a..d99a459 100644
--- a/planetwars-server/src/db/bots.rs
+++ b/planetwars-server/src/db/bots.rs
@@ -34,6 +34,10 @@ pub fn find_bots_by_owner(owner_id: i32, conn: &PgConnection) -> QueryResult<Vec
.get_results(conn)
}
+pub fn find_bot_by_name(name: &str, conn: &PgConnection) -> QueryResult<Bot> {
+ bots::table.filter(bots::name.eq(name)).first(conn)
+}
+
pub fn find_all_bots(conn: &PgConnection) -> QueryResult<Vec<Bot>> {
// TODO: filter out bots that cannot be run (have no valid code bundle associated with them)
bots::table.get_results(conn)