summaryrefslogtreecommitdiffstats
path: root/src/db/models/endpoint.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-04-22 10:34:34 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-04-22 10:34:34 +0200
commitd86d6ff045725bb313ca68652f76ec7f1f82714f (patch)
tree690911ed45a22d93d51bdfb5c9d16f2d43422789 /src/db/models/endpoint.rs
parentdfeb8312ebf34479ccb82faae116ed242d372f86 (diff)
parentf6229edd41292e19d8c18a81a86542741260e938 (diff)
Merge branch 'subcommand-submit'
Diffstat (limited to 'src/db/models/endpoint.rs')
-rw-r--r--src/db/models/endpoint.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/db/models/endpoint.rs b/src/db/models/endpoint.rs
index d7a7986..3909b2b 100644
--- a/src/db/models/endpoint.rs
+++ b/src/db/models/endpoint.rs
@@ -43,4 +43,16 @@ impl Endpoint {
.first::<Endpoint>(database_connection)
.map_err(Error::from)
}
+
+ pub fn fetch_for_job(database_connection: &PgConnection, j: &crate::db::models::Job) -> Result<Option<Endpoint>> {
+ Self::fetch_by_id(database_connection, j.endpoint_id)
+ }
+
+ pub fn fetch_by_id(database_connection: &PgConnection, eid: i32) -> Result<Option<Endpoint>> {
+ match dsl::endpoints.filter(id.eq(eid)).first::<Endpoint>(database_connection) {
+ Err(diesel::result::Error::NotFound) => Ok(None),
+ Err(e) => Err(Error::from(e)),
+ Ok(e) => Ok(Some(e)),
+ }
+ }
}