random styling and shit
This commit is contained in:
parent
a09ec898f9
commit
5831d974ec
5 changed files with 62 additions and 56 deletions
|
@ -1,10 +1,7 @@
|
||||||
use std::{ffi::OsString, time::Duration};
|
use std::{ffi::OsString, time::Duration};
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use sqlx::{
|
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
|
||||||
query_as,
|
|
||||||
sqlite::{SqliteConnectOptions, SqlitePoolOptions},
|
|
||||||
};
|
|
||||||
use what2watch::{get_db_pool, import_utils::add_omega_watches};
|
use what2watch::{get_db_pool, import_utils::add_omega_watches};
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
@ -42,7 +39,7 @@ fn main() {
|
||||||
|
|
||||||
let w2w_db = get_db_pool();
|
let w2w_db = get_db_pool();
|
||||||
|
|
||||||
let dur = {
|
let (dur, rows) = {
|
||||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()
|
.build()
|
||||||
|
@ -50,33 +47,16 @@ fn main() {
|
||||||
|
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
let dur = add_omega_watches(&w2w_db, &movie_db, num).await.unwrap();
|
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;
|
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!(
|
println!(
|
||||||
"Added {rows} movies in {} seconds ({}ms, {}us)",
|
"Added {rows} movies in {} seconds ({}ms, {}us)",
|
||||||
dur.as_secs_f64(),
|
dur.as_secs_f64(),
|
||||||
|
|
|
@ -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 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
|
// 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 struct ImportMovieOmega {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub year: Option<String>,
|
pub year: Option<String>,
|
||||||
pub length: Option<String>,
|
pub runtime: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ImportMovieOmega> for Watch {
|
impl From<ImportMovieOmega> for Watch {
|
||||||
|
@ -28,7 +28,7 @@ impl From<ImportMovieOmega> for Watch {
|
||||||
id: OMEGA_ID, // this is ignored by the inserter
|
id: OMEGA_ID, // this is ignored by the inserter
|
||||||
title: value.title,
|
title: value.title,
|
||||||
release_date: year_to_epoch(value.year.as_deref()),
|
release_date: year_to_epoch(value.year.as_deref()),
|
||||||
length: value.length.and_then(|v| v.parse::<i64>().ok()),
|
length: value.runtime.and_then(|v| v.parse::<i64>().ok()),
|
||||||
kind: ShowKind::Movie,
|
kind: ShowKind::Movie,
|
||||||
metadata_url: None,
|
metadata_url: None,
|
||||||
added_by: OMEGA_ID,
|
added_by: OMEGA_ID,
|
||||||
|
@ -42,7 +42,7 @@ impl From<&ImportMovieOmega> for Watch {
|
||||||
id: OMEGA_ID,
|
id: OMEGA_ID,
|
||||||
title: value.title.to_string(),
|
title: value.title.to_string(),
|
||||||
release_date: year_to_epoch(value.year.as_deref()),
|
release_date: year_to_epoch(value.year.as_deref()),
|
||||||
length: value.length.as_ref().and_then(|v| v.parse::<i64>().ok()),
|
length: value.runtime.as_ref().and_then(|v| v.parse::<i64>().ok()),
|
||||||
kind: ShowKind::Movie,
|
kind: ShowKind::Movie,
|
||||||
metadata_url: None,
|
metadata_url: None,
|
||||||
added_by: OMEGA_ID,
|
added_by: OMEGA_ID,
|
||||||
|
@ -112,7 +112,7 @@ pub async fn add_omega_watches(
|
||||||
let title = &movie.title;
|
let title = &movie.title;
|
||||||
b.push_bind(ShowKind::Movie)
|
b.push_bind(ShowKind::Movie)
|
||||||
.push_bind(title)
|
.push_bind(title)
|
||||||
.push_bind(movie.length.as_ref().and_then(|l| l.parse::<i64>().ok()))
|
.push_bind(movie.runtime.as_ref().and_then(|l| l.parse::<i64>().ok()))
|
||||||
.push_bind(year_to_epoch(movie.year.as_deref()))
|
.push_bind(year_to_epoch(movie.year.as_deref()))
|
||||||
.push_bind(omega);
|
.push_bind(omega);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
p {
|
body {
|
||||||
color: red
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
{% when Some with (usr) %}
|
{% when Some with (usr) %}
|
||||||
<div class="header_logged_in">
|
<div class="header_logged_in">
|
||||||
Hello, {{ usr.username }}!
|
Hello, {{ usr.username }}!
|
||||||
</div>
|
<div>
|
||||||
<div>
|
<form action="/logout" enctype="application/x-www-form-urlencoded" method="post">
|
||||||
<form action="/logout" enctype="application/x-www-form-urlencoded" method="post">
|
<button>
|
||||||
<button class="warning">
|
<input type="submit" value="sign out?" class="warning">
|
||||||
<input type="submit" value="sign out?">
|
</button>
|
||||||
</button>
|
</form>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% else %} <!-- this is for the `when` statement -->
|
{% else %} <!-- this is for the `when` statement -->
|
||||||
|
@ -19,8 +19,8 @@
|
||||||
</div>
|
</div>
|
||||||
{% endmatch %}
|
{% endmatch %}
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
{% else %} <!-- this is for whether or not the template has a user field or not -->
|
{% else %} <!-- this is for whether or not the template has a user field or not -->
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
|
@ -8,29 +8,34 @@
|
||||||
<h1>Whatcha Watchin?</h1>
|
<h1>Whatcha Watchin?</h1>
|
||||||
|
|
||||||
{% match user %}
|
{% match user %}
|
||||||
{% when Some with (usr) %}
|
{% when Some with (usr) %}
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
Hello, {{ usr.username }}! It's nice to see you.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Hello, {{ usr.username }}! It's nice to see you.
|
<form action="/search" enctype="application/x-www-form-urlencoded" method="get">
|
||||||
|
<label for="search">Looking for something else to watch?</label>
|
||||||
|
<input type="text" name="search" id="search"></br>
|
||||||
|
<input type="submit" value="Let's go!">
|
||||||
|
</form>
|
||||||
</p>
|
</p>
|
||||||
</br>
|
|
||||||
<p>Here are your things to watch:</p>
|
<p>Here are your things to watch:</p>
|
||||||
<div class="watchlist">
|
<div class="watchlist">
|
||||||
<ul>
|
<ul>
|
||||||
{% for watch in watches %}
|
{% for watch in watches %}
|
||||||
<li><span class="watchtitle">{{watch.title}}</span> -- {% call m::get_or_default(watch.year(), "when??") %}: </li>
|
<li><span class="watchtitle">{{watch.title}}</span> -- {% call m::get_or_default(watch.year(), "when??") %}:
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
|
||||||
<form action="/search" enctype="application/x-www-form-urlencoded" method="get">
|
|
||||||
<label for="search">Looking for something else to watch?</label>
|
|
||||||
<input type="text" name="search" id="search"></br>
|
|
||||||
<input type="submit" value="Let's go!">
|
|
||||||
</form>
|
|
||||||
</p>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
Heya, why don't you <a href="/login">log in</a> or <a href="/signup">sign up</a>?
|
Heya, why don't you <a href="/login">log in</a> or <a href="/signup">sign up</a>?
|
||||||
</p>
|
</p>
|
||||||
{% endmatch %}
|
{% endmatch %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue