Skip to content

Commit

Permalink
Fixed gpodder sync
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Sep 2, 2024
1 parent c7baebe commit 1a97587
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/models/episode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::dbconfig::schema::episodes::dsl::episodes as episodes_dsl;
use crate::DBType as DbConnection;
use chrono::{NaiveDateTime, Utc};
use diesel::sql_types::{Integer, Nullable, Text, Timestamp};
use diesel::{ExpressionMethods, JoinOnDsl};
use diesel::{debug_query, ExpressionMethods, JoinOnDsl};

Check failure on line 7 in src/models/episode.rs

View workflow job for this annotation

GitHub Actions / Rust lint

unused import: `debug_query`

Check warning on line 7 in src/models/episode.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused import: `debug_query`
use diesel::{
BoolExpressionMethods, Insertable, NullableExpressionMethods, OptionalExtension, QueryDsl,
QueryId, Queryable, QueryableByName, RunQueryDsl, Selectable,
Expand All @@ -14,7 +14,9 @@ use serde::{Deserialize, Serialize};
use std::fmt;
use std::io::Error;
use diesel::query_dsl::methods::DistinctDsl;
use diesel::sqlite::Sqlite;

Check failure on line 17 in src/models/episode.rs

View workflow job for this annotation

GitHub Actions / Rust lint

unused import: `diesel::sqlite::Sqlite`

Check warning on line 17 in src/models/episode.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused import: `diesel::sqlite::Sqlite`
use utoipa::ToSchema;
use crate::dbconfig::{DBType, MultiBackend};

Check failure on line 19 in src/models/episode.rs

View workflow job for this annotation

GitHub Actions / Rust lint

unused imports: `DBType` and `MultiBackend`

Check warning on line 19 in src/models/episode.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused imports: `DBType` and `MultiBackend`
use crate::models::gpodder_available_podcasts::GPodderAvailablePodcasts;
use crate::models::misc_models::{
PodcastWatchedEpisodeModelWithPodcastEpisode, PodcastWatchedPostModel,
Expand Down Expand Up @@ -150,8 +152,9 @@ impl Episode {

let mut query = ep_table.filter(username.eq(username1)).into_boxed();

println!("Since {}", since_date.unwrap());
if let Some(since_date) = since_date {
query = query.filter(timestamp.gt(since_date));
query = query.filter(timestamp.ge(since_date));
}

if let Some(device) = opt_device {
Expand All @@ -161,12 +164,15 @@ impl Episode {
.eq(device)
.or(ep_dsl::device.eq(DEFAULT_DEVICE)),
);
} else {
query = query.filter(ep_dsl::device.eq(DEFAULT_DEVICE))
}

if let Some(podcast) = opt_podcast {
query = query.filter(ep_dsl::podcast.eq(podcast));
}


query
.load::<Episode>(conn)
.expect("Error querying episodes")
Expand Down Expand Up @@ -385,13 +391,14 @@ impl Episode {
return Ok(());
}
Ok(None) => {
let naive_date = Utc::now().naive_utc();
let episode = Episode {
id,
username,
device: DEFAULT_DEVICE.to_string(),
podcast: podcast.unwrap().rssfeed,
episode: found_episode.url.clone(),
timestamp: Default::default(),
timestamp: naive_date,
guid: Some(found_episode.guid.clone()),
action: "play".to_string(),
started: None,
Expand Down

0 comments on commit 1a97587

Please sign in to comment.