Compare commits
No commits in common. "0e170c04287f7ce39890a6888c851abda0ad12e9" and "4e2e8e585ff40f7ee8cc708c4adcc9501401b180" have entirely different histories.
0e170c0428
...
4e2e8e585f
12 changed files with 55 additions and 49 deletions
|
@ -25,35 +25,30 @@ 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 year: Option<String>,
|
||||
pub kind: Option<String>,
|
||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
||||
pub person: Option<String>,
|
||||
pub year: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn get_search_watch(
|
||||
auth: AuthSession,
|
||||
State(pool): State<SqlitePool>,
|
||||
Query(search): Query<SearchQuery>,
|
||||
search: Query<SearchQuery>,
|
||||
) -> impl IntoResponse {
|
||||
let user = auth.user;
|
||||
let SearchQuery {
|
||||
title,
|
||||
year,
|
||||
person,
|
||||
} = &search;
|
||||
let search_query = search.0;
|
||||
|
||||
let watches: Vec<Watch> = match (title, year, person) {
|
||||
(Some(title), None, None) => sqlx::query_as(
|
||||
let watches: Vec<Watch> = if let Some(title) = search_query.title {
|
||||
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(),
|
||||
(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()
|
||||
&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()
|
||||
};
|
||||
|
||||
SearchPage {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
{% import "macros.html" as m %}
|
||||
|
||||
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
{% import "macros.html" as m %}
|
||||
|
||||
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Login to What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Login to What 2 Watch, Bish{% endblock %}
|
||||
|
||||
{% block header %}{% endblock %}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Logout of What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Logout of What 2 Watch, Bish{% endblock %}
|
||||
|
||||
{% block header %}{% endblock %}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Thanks for Signing Up for What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Thanks for Signing Up for What 2 Watch, Bish{% endblock %}
|
||||
|
||||
{% block header %}{% endblock %}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
{% import "macros.html" as m %}
|
||||
|
||||
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
|
|
@ -1,33 +1,11 @@
|
|||
{% extends "base.html" %}
|
||||
{% import "macros.html" as m %}
|
||||
|
||||
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Welcome to What 2 Watch, Bish{% 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>
|
||||
|
@ -45,6 +23,39 @@
|
|||
{% 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 %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Sign Up for What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Sign Up for What 2 Watch, Bish{% endblock %}
|
||||
|
||||
{% block header %} {% endblock %}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Dang, Buddy{% endblock %}
|
||||
{% block title %}Dang, Bish{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% block header %}{% endblock %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Thanks for Signing Up for What 2 Watch, Buddy{% endblock %}
|
||||
{% block title %}Thanks for Signing Up for What 2 Watch, Bish{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% block header %}{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue