Better naming of a dbquery function.

This commit is contained in:
Jordan Petridis 2017-12-10 06:11:03 +02:00
parent bc57c33491
commit d8281c70a5
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
3 changed files with 9 additions and 17 deletions

View File

@ -155,12 +155,7 @@ pub fn get_podcast_from_source_id(sid: i32) -> Result<Podcast> {
.get_result::<Podcast>(&*con)?)
}
// TODO: unhack me
pub fn get_episode_from_new_episode(
con: &SqliteConnection,
title_: &str,
pid: i32,
) -> QueryResult<Episode> {
pub fn get_episode_from_pk(con: &SqliteConnection, title_: &str, pid: i32) -> QueryResult<Episode> {
use schema::episode::dsl::*;
episode

View File

@ -193,7 +193,7 @@ impl NewEpisode {
// TODO: Refactor into batch indexes instead.
pub(crate) fn into_episode(self, con: &SqliteConnection) -> Result<Episode> {
self.index(con)?;
Ok(dbqueries::get_episode_from_new_episode(
Ok(dbqueries::get_episode_from_pk(
con,
&self.title,
self.podcast_id,
@ -201,8 +201,7 @@ impl NewEpisode {
}
pub(crate) fn index(&self, con: &SqliteConnection) -> QueryResult<()> {
// TODO: Change me
let ep = dbqueries::get_episode_from_new_episode(con, &self.title, self.podcast_id);
let ep = dbqueries::get_episode_from_pk(con, &self.title, self.podcast_id);
match ep {
Ok(foo) => {

View File

@ -162,10 +162,8 @@ mod tests {
.into_episode(&con)
.unwrap();
let mut ep1 =
dbqueries::get_episode_from_new_episode(&con, n1.title(), n1.podcast_id()).unwrap();
let mut ep2 =
dbqueries::get_episode_from_new_episode(&con, n2.title(), n2.podcast_id()).unwrap();
let mut ep1 = dbqueries::get_episode_from_pk(&con, n1.title(), n1.podcast_id()).unwrap();
let mut ep2 = dbqueries::get_episode_from_pk(&con, n2.title(), n2.podcast_id()).unwrap();
ep1.set_local_uri(Some(valid_path.to_str().unwrap()));
ep2.set_local_uri(Some(bad_path.to_str().unwrap()));
@ -192,7 +190,7 @@ mod tests {
let mut episode = {
let db = connection();
let con = db.get().unwrap();
dbqueries::get_episode_from_new_episode(&con, "bar_baz", 1).unwrap()
dbqueries::get_episode_from_pk(&con, "bar_baz", 1).unwrap()
};
checker_helper(&mut episode);
@ -205,7 +203,7 @@ mod tests {
let mut episode = {
let db = connection();
let con = db.get().unwrap();
dbqueries::get_episode_from_new_episode(&con, "foo_bar", 0).unwrap()
dbqueries::get_episode_from_pk(&con, "foo_bar", 0).unwrap()
};
let valid_path = episode.local_uri().unwrap().to_owned();
@ -219,7 +217,7 @@ mod tests {
let mut episode = {
let db = connection();
let con = db.get().unwrap();
dbqueries::get_episode_from_new_episode(&con, "foo_bar", 0).unwrap()
dbqueries::get_episode_from_pk(&con, "foo_bar", 0).unwrap()
};
let now_utc = Utc::now().timestamp() as i32;
// let limit = now_utc - 172_800;
@ -239,7 +237,7 @@ mod tests {
let mut episode = {
let db = connection();
let con = db.get().unwrap();
dbqueries::get_episode_from_new_episode(&con, "foo_bar", 0).unwrap()
dbqueries::get_episode_from_pk(&con, "foo_bar", 0).unwrap()
};
let now_utc = Utc::now().timestamp() as i32;
// limit = 172_800;