aboutsummaryrefslogtreecommitdiffstats
path: root/src/db.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2019-04-28 13:47:58 +0200
committerHarald Eilertsen <haraldei@anduin.net>2019-04-28 13:47:58 +0200
commitcaa7b4429e68135404ad5a01aa1d7f530abae090 (patch)
tree2f2b2331de7e126bc2552c4e285cd75f69256cf4 /src/db.rs
parent30f65b62e84fcd9975643716d61fa21bc8495291 (diff)
downloadramaskrik-social-caa7b4429e68135404ad5a01aa1d7f530abae090.tar.gz
ramaskrik-social-caa7b4429e68135404ad5a01aa1d7f530abae090.tar.bz2
ramaskrik-social-caa7b4429e68135404ad5a01aa1d7f530abae090.zip
Update /screenings endpoint to return full info on screenings.
This makes each screening record self-contained, and the json payload more consistent with how it semantically fit together.
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/db.rs b/src/db.rs
index d7a12b0..d24384f 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -53,12 +53,13 @@ impl Connection {
.execute(&**self)
}
- pub fn get_screenings(&self) -> QueryResult<Vec<(models::Screening, Option<models::Film>, Option<models::Room>)>> {
+ pub fn get_screenings(&self) -> QueryResult<Vec<models::Screening>> {
use crate::schema::screenings::dsl::*;
- screenings
+ let s = screenings
.left_join(films::table)
.left_join(rooms::table)
- .get_results(&**self)
+ .get_results(&**self)?;
+ Ok(models::Screening::from_query(s))
}
pub fn get_rooms(&self) -> QueryResult<Vec<models::Room>> {