Made Disel NewModels private.
This commit is contained in:
@@ -12,7 +12,7 @@ use rayon::prelude::*;
|
||||
|
||||
use test::Bencher;
|
||||
|
||||
use hammond_data::models::NewSource;
|
||||
use hammond_data::Source;
|
||||
use hammond_data::feed::{index, Feed};
|
||||
|
||||
use std::io::BufReader;
|
||||
@@ -36,7 +36,7 @@ fn index_urls() {
|
||||
URLS.par_iter()
|
||||
.map(|&(buff, url)| {
|
||||
// Create and insert a Source into db
|
||||
let s = NewSource::new_with_uri(url).into_source().unwrap();
|
||||
let s = Source::from_url(url).unwrap();
|
||||
// parse it into a channel
|
||||
let chan = rss::Channel::read_from(BufReader::new(buff)).unwrap();
|
||||
Feed::from_channel_source(chan, s)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
use diesel::prelude::*;
|
||||
use diesel;
|
||||
use models::{Episode, NewEpisode, NewPodcast, NewSource, Podcast, Source};
|
||||
|
||||
@@ -33,7 +33,7 @@ impl Feed {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn index_channel(&self) -> Result<Podcast> {
|
||||
pub fn index_channel(&self) -> Result<Podcast> {
|
||||
let pd = parser::new_podcast(&self.channel, *self.source.id());
|
||||
// Convert NewPodcast to Podcast
|
||||
pd.into_podcast()
|
||||
|
||||
@@ -27,9 +27,9 @@ extern crate xdg;
|
||||
|
||||
pub mod dbqueries;
|
||||
pub mod utils;
|
||||
pub mod models;
|
||||
pub mod feed;
|
||||
pub mod errors;
|
||||
mod models;
|
||||
mod parser;
|
||||
mod schema;
|
||||
|
||||
@@ -41,6 +41,8 @@ use std::path::PathBuf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
// use std::time::Duration;
|
||||
|
||||
pub use models::{Episode, Podcast, Source};
|
||||
|
||||
// type Pool = r2d2::Pool<ConnectionManager<SqliteConnection>>;
|
||||
type Database = Arc<Mutex<SqliteConnection>>;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ impl<'a> NewSource<'a> {
|
||||
|
||||
#[derive(Insertable)]
|
||||
#[table_name = "episode"]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct NewEpisode<'a> {
|
||||
pub title: Option<&'a str>,
|
||||
pub uri: Option<String>,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
use reqwest;
|
||||
use diesel::SaveChangesDsl;
|
||||
use diesel::result::QueryResult;
|
||||
@@ -9,7 +8,7 @@ use schema::{episode, podcast, source};
|
||||
use feed::Feed;
|
||||
use errors::*;
|
||||
|
||||
use models::insertables::NewPodcast;
|
||||
use models::insertables::NewSource;
|
||||
use connection;
|
||||
|
||||
use std::io::Read;
|
||||
@@ -153,23 +152,6 @@ pub struct Podcast {
|
||||
source_id: i32,
|
||||
}
|
||||
|
||||
/// This is meant only to be used to make unit tests easier.
|
||||
impl From<NewPodcast> for Podcast {
|
||||
fn from(pd: NewPodcast) -> Podcast {
|
||||
Podcast {
|
||||
id: 0,
|
||||
title: pd.title,
|
||||
link: pd.link,
|
||||
description: pd.description,
|
||||
image_uri: pd.image_uri,
|
||||
source_id: pd.source_id,
|
||||
always_dl: false,
|
||||
archive: false,
|
||||
favorite: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Podcast {
|
||||
pub fn source_id(&self) -> i32 {
|
||||
self.source_id
|
||||
@@ -336,4 +318,8 @@ impl<'a> Source {
|
||||
|
||||
Ok(Feed::from_channel_source(chan, self))
|
||||
}
|
||||
|
||||
pub fn from_url(uri: &str) -> QueryResult<Source> {
|
||||
NewSource::new_with_uri(uri).into_source()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user