Compare commits

...

2 commits

Author SHA1 Message Date
Joe Ardent
0e170c0428 hey buddy. 2024-04-11 22:15:34 -07:00
Joe Ardent
a45ca8d3a5 simplify search, sketch out search-branches. 2024-04-11 22:15:09 -07:00
12 changed files with 49 additions and 55 deletions

View file

@ -25,30 +25,35 @@ pub enum SearchResult {
#[derive(Debug, Default, Clone, Deserialize, PartialEq, Eq)]
pub struct SearchQuery {
#[serde(default, deserialize_with = "empty_string_as_none")]
pub search: Option<String>,
#[serde(default, deserialize_with = "empty_string_as_none")]
pub title: Option<String>,
#[serde(default, deserialize_with = "empty_string_as_none")]
pub kind: Option<String>,
#[serde(default, deserialize_with = "empty_string_as_none")]
pub year: Option<String>,
#[serde(default, deserialize_with = "empty_string_as_none")]
pub person: Option<String>,
}
pub async fn get_search_watch(
auth: AuthSession,
State(pool): State<SqlitePool>,
search: Query<SearchQuery>,
Query(search): Query<SearchQuery>,
) -> impl IntoResponse {
let user = auth.user;
let search_query = search.0;
let SearchQuery {
title,
year,
person,
} = &search;
let watches: Vec<Watch> = if let Some(title) = search_query.title {
sqlx::query_as(
let watches: Vec<Watch> = match (title, year, person) {
(Some(title), None, None) => sqlx::query_as(
"select * from watches where id in (select id from watch_search where title match ? order by rank)").bind(
&title).fetch_all(&pool).await.unwrap_or_default()
} else {
sqlx::query_as("select * from (select * from watches order by random() limit 50) order by release_date asc").fetch_all(&pool).await.unwrap_or_default()
title).fetch_all(&pool).await.unwrap_or_default(),
(Some(title), Some(year), None) => {todo!()},
(None, Some(year), None) => {todo!()},
(None, Some(year), Some(person)) => {todo!()},
(Some(title), Some(year), Some(person)) => {todo!()}
_ => sqlx::query_as("select * from (select * from watches order by random() limit 50) order by release_date asc").fetch_all(&pool).await.unwrap_or_default()
};
SearchPage {

View file

@ -1,7 +1,7 @@
{% extends "base.html" %}
{% import "macros.html" as m %}
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
{% block content %}

View file

@ -1,7 +1,7 @@
{% extends "base.html" %}
{% import "macros.html" as m %}
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
{% block content %}

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
{% block content %}

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block title %}Login to What 2 Watch, Bish{% endblock %}
{% block title %}Login to What 2 Watch, Buddy{% endblock %}
{% block header %}{% endblock %}

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block title %}Logout of What 2 Watch, Bish{% endblock %}
{% block title %}Logout of What 2 Watch, Buddy{% endblock %}
{% block header %}{% endblock %}

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block title %}Thanks for Signing Up for What 2 Watch, Bish{% endblock %}
{% block title %}Thanks for Signing Up for What 2 Watch, Buddy{% endblock %}
{% block header %}{% endblock %}

View file

@ -1,7 +1,7 @@
{% extends "base.html" %}
{% import "macros.html" as m %}
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
{% block content %}

View file

@ -1,11 +1,33 @@
{% extends "base.html" %}
{% import "macros.html" as m %}
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
{% block content %}
<h1>Whatcha Watchin?</h1>
<div class="fullsearch">
<form action="/search" enctype="application/x-www-form-urlencoded" method="get">
<h2>Search</h2>
<label for="title">Title</label>
<input type="text" name="title" id="title-search"></br>
<label for="year">Release Year</label>
<input type="text" name="year" id="title-year-search"></br>
<hr>
<label for="person">Person</label>
<input type="text" name="person" id="person-search"></br>
<input type="submit" value="Let's go!">
</form>
</div>
<hr />
<div class="watchlist">
<table>
<thead>
@ -23,39 +45,6 @@
{% endfor %}
</tbody>
</table>
<hr />
</div>
<h2>Simple Search</h2>
<div class="simplesearch">
<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!">
</div>
<h2>Fussy Search</h2>
<div class="fullsearch">
<label for="title">Title</label>
<input type="text" name="title" id="title"></br>
<label for="year">Release Year</label>
<input type="text" name="year" id="year"></br>
<label for="kind">Type</label>
<select id="kind" name="kind">
<option value="">Unknown</option>
<option value="0">Movie</option>
<option value="1">Series</option>
<option value="2">Limited Series</option>
<option value="3">Short</option>
<option value="4">Other</option>
</select>
<input type="submit" value="Let's go!">
</form>
</div>
{% endblock %}

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block title %}Sign Up for What 2 Watch, Bish{% endblock %}
{% block title %}Sign Up for What 2 Watch, Buddy{% endblock %}
{% block header %} {% endblock %}

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block title %}Dang, Bish{% endblock %}
{% block title %}Dang, Buddy{% endblock %}
{% block content %}
{% block header %}{% endblock %}

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block title %}Thanks for Signing Up for What 2 Watch, Bish{% endblock %}
{% block title %}Thanks for Signing Up for What 2 Watch, Buddy{% endblock %}
{% block content %}
{% block header %}{% endblock %}