Better naming of a dbquery function.
This commit is contained in:
parent
bc57c33491
commit
d8281c70a5
@ -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
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user