diff --git a/src/bin/import_omega.rs b/src/bin/import_omega.rs index a151395..02925bc 100644 --- a/src/bin/import_omega.rs +++ b/src/bin/import_omega.rs @@ -1,10 +1,7 @@ use std::{ffi::OsString, time::Duration}; use clap::Parser; -use sqlx::{ - query_as, - sqlite::{SqliteConnectOptions, SqlitePoolOptions}, -}; +use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use what2watch::{get_db_pool, import_utils::add_omega_watches}; #[derive(Debug, Parser)] @@ -42,7 +39,7 @@ fn main() { let w2w_db = get_db_pool(); - let dur = { + let (dur, rows) = { let rt = tokio::runtime::Builder::new_multi_thread() .enable_all() .build() @@ -50,33 +47,16 @@ fn main() { rt.block_on(async { let dur = add_omega_watches(&w2w_db, &movie_db, num).await.unwrap(); + let rows: i32 = sqlx::query_scalar("select count(*) from watches") + .fetch_one(&w2w_db) + .await + .unwrap(); + w2w_db.close().await; - dur + (dur, rows) }) }; - let w2w_db = get_db_pool(); - let movies: Vec<(String, f64, i64)> = { - let rt = tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap(); - let movies = rt.block_on( - query_as( - "select julid_string(id), julid_seconds(id) * 1000, julid_counter(id) from watches", - ) - .fetch_all(&w2w_db), - ) - .unwrap(); - rt.block_on(w2w_db.close()); - movies - }; - let rows = movies.len(); - - for m in movies.iter() { - println!("{}: {}ms, {} count", m.0, m.1, m.2); - } - println!( "Added {rows} movies in {} seconds ({}ms, {}us)", dur.as_secs_f64(), diff --git a/src/import_utils.rs b/src/import_utils.rs index 23fe3b8..0121c79 100644 --- a/src/import_utils.rs +++ b/src/import_utils.rs @@ -7,7 +7,7 @@ use crate::{util::year_to_epoch, ShowKind, User, Watch, WatchQuest}; const USER_EXISTS_QUERY: &str = "select count(*) from users where id = $1"; -const MOVIE_QUERY: &str = "select * from movies order by random() limit ?"; +const MOVIE_QUERY: &str = "select * from movie_titles order by year, title asc limit ?"; //-************************************************************************ // the omega user is the system ID, but has no actual power in the app @@ -19,7 +19,7 @@ const BULK_INSERT: usize = 2_000; pub struct ImportMovieOmega { pub title: String, pub year: Option, - pub length: Option, + pub runtime: Option, } impl From for Watch { @@ -28,7 +28,7 @@ impl From for Watch { id: OMEGA_ID, // this is ignored by the inserter title: value.title, release_date: year_to_epoch(value.year.as_deref()), - length: value.length.and_then(|v| v.parse::().ok()), + length: value.runtime.and_then(|v| v.parse::().ok()), kind: ShowKind::Movie, metadata_url: None, added_by: OMEGA_ID, @@ -42,7 +42,7 @@ impl From<&ImportMovieOmega> for Watch { id: OMEGA_ID, title: value.title.to_string(), release_date: year_to_epoch(value.year.as_deref()), - length: value.length.as_ref().and_then(|v| v.parse::().ok()), + length: value.runtime.as_ref().and_then(|v| v.parse::().ok()), kind: ShowKind::Movie, metadata_url: None, added_by: OMEGA_ID, @@ -112,7 +112,7 @@ pub async fn add_omega_watches( let title = &movie.title; b.push_bind(ShowKind::Movie) .push_bind(title) - .push_bind(movie.length.as_ref().and_then(|l| l.parse::().ok())) + .push_bind(movie.runtime.as_ref().and_then(|l| l.parse::().ok())) .push_bind(year_to_epoch(movie.year.as_deref())) .push_bind(omega); }); diff --git a/templates/css/ww.css b/templates/css/ww.css index a99c844..9cafdc9 100644 --- a/templates/css/ww.css +++ b/templates/css/ww.css @@ -1,3 +1,24 @@ -p { - color: red +body { + background-color: darkgrey +} + +#header { + text-align: end; + display: flex; + flex-direction: row; + justify-content: flex-end; + +} + +.warning { + background-color: goldenrod; +} + +.watchlist { + background-color: ghostwhite; +} + +.header_logged_in { + display: flex; + flex-direction: column; } diff --git a/templates/header_with_user.html b/templates/header_with_user.html index 27a9e3e..83976aa 100644 --- a/templates/header_with_user.html +++ b/templates/header_with_user.html @@ -4,13 +4,13 @@ {% when Some with (usr) %}
Hello, {{ usr.username }}! -
-
-
- -
+
+
+ +
+
{% else %} @@ -19,8 +19,8 @@ {% endmatch %} +
+ {% else %} {% endif %} - -
diff --git a/templates/my_watches_page.html b/templates/my_watches_page.html index af0df05..0ed8428 100644 --- a/templates/my_watches_page.html +++ b/templates/my_watches_page.html @@ -8,29 +8,34 @@

Whatcha Watchin?

{% match user %} - {% when Some with (usr) %} +{% when Some with (usr) %} +
+

+ Hello, {{ usr.username }}! It's nice to see you. +

+
+ +

-Hello, {{ usr.username }}! It's nice to see you. +

+ +
+ +

-
+

Here are your things to watch:

    {% for watch in watches %} -
  • {{watch.title}} -- {% call m::get_or_default(watch.year(), "when??") %}:
  • +
  • {{watch.title}} -- {% call m::get_or_default(watch.year(), "when??") %}: +
  • {% endfor %}
-

-

- -
- -
-

{% else %}

- Heya, why don't you log in or sign up? + Heya, why don't you log in or sign up?

{% endmatch %}