Compare commits
2 commits
4e2e8e585f
...
0e170c0428
Author | SHA1 | Date | |
---|---|---|---|
|
0e170c0428 | ||
|
a45ca8d3a5 |
12 changed files with 49 additions and 55 deletions
|
@ -25,30 +25,35 @@ pub enum SearchResult {
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Deserialize, PartialEq, Eq)]
|
#[derive(Debug, Default, Clone, Deserialize, PartialEq, Eq)]
|
||||||
pub struct SearchQuery {
|
pub struct SearchQuery {
|
||||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
|
||||||
pub search: Option<String>,
|
|
||||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
#[serde(default, deserialize_with = "empty_string_as_none")]
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
#[serde(default, deserialize_with = "empty_string_as_none")]
|
||||||
pub kind: Option<String>,
|
|
||||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
|
||||||
pub year: Option<String>,
|
pub year: Option<String>,
|
||||||
|
#[serde(default, deserialize_with = "empty_string_as_none")]
|
||||||
|
pub person: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_search_watch(
|
pub async fn get_search_watch(
|
||||||
auth: AuthSession,
|
auth: AuthSession,
|
||||||
State(pool): State<SqlitePool>,
|
State(pool): State<SqlitePool>,
|
||||||
search: Query<SearchQuery>,
|
Query(search): Query<SearchQuery>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
let user = auth.user;
|
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 {
|
let watches: Vec<Watch> = match (title, year, person) {
|
||||||
sqlx::query_as(
|
(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(
|
"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()
|
title).fetch_all(&pool).await.unwrap_or_default(),
|
||||||
} else {
|
(Some(title), Some(year), None) => {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()
|
(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 {
|
SearchPage {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% import "macros.html" as m %}
|
{% 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 %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% import "macros.html" as m %}
|
{% 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 %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}Welcome to What 2 Watch, Bish{% endblock %}
|
{% block title %}Welcome to What 2 Watch, Buddy{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}Login to What 2 Watch, Bish{% endblock %}
|
{% block title %}Login to What 2 Watch, Buddy{% endblock %}
|
||||||
|
|
||||||
{% block header %}{% endblock %}
|
{% block header %}{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}Logout of What 2 Watch, Bish{% endblock %}
|
{% block title %}Logout of What 2 Watch, Buddy{% endblock %}
|
||||||
|
|
||||||
{% block header %}{% endblock %}
|
{% block header %}{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% 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 %}
|
{% block header %}{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% import "macros.html" as m %}
|
{% 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 %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,33 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% import "macros.html" as m %}
|
{% 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 %}
|
{% block content %}
|
||||||
|
|
||||||
<h1>Whatcha Watchin?</h1>
|
<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">
|
<div class="watchlist">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -23,39 +45,6 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</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>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% 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 %}
|
{% block header %} {% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}Dang, Bish{% endblock %}
|
{% block title %}Dang, Buddy{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% block header %}{% endblock %}
|
{% block header %}{% endblock %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% 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 content %}
|
||||||
{% block header %}{% endblock %}
|
{% block header %}{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue