mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-12-23 02:26:36 +00:00
Clippy
This commit is contained in:
parent
3d192c1179
commit
4f796e788c
3 changed files with 7 additions and 7 deletions
|
@ -756,7 +756,7 @@ impl FromId<DbConn> for Post {
|
||||||
let timestamp_secs = published.unix_timestamp();
|
let timestamp_secs = published.unix_timestamp();
|
||||||
let timestamp_nanos = published.unix_timestamp_nanos()
|
let timestamp_nanos = published.unix_timestamp_nanos()
|
||||||
- (timestamp_secs as i128) * 1000i128 * 1000i128 * 1000i128;
|
- (timestamp_secs as i128) * 1000i128 * 1000i128 * 1000i128;
|
||||||
NaiveDateTime::from_timestamp(timestamp_secs, timestamp_nanos as u32)
|
NaiveDateTime::from_timestamp_opt(timestamp_secs, timestamp_nanos as u32).unwrap()
|
||||||
}),
|
}),
|
||||||
subtitle: article
|
subtitle: article
|
||||||
.summary()
|
.summary()
|
||||||
|
|
|
@ -94,7 +94,7 @@ macro_rules! gen_to_string {
|
||||||
)*
|
)*
|
||||||
$(
|
$(
|
||||||
for val in &$self.$date {
|
for val in &$self.$date {
|
||||||
$result.push_str(&format!("{}:{} ", stringify!($date), NaiveDate::from_num_days_from_ce(*val as i32).format("%Y-%m-%d")));
|
$result.push_str(&format!("{}:{} ", stringify!($date), NaiveDate::from_num_days_from_ce_opt(*val as i32).unwrap().format("%Y-%m-%d")));
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
@ -182,10 +182,10 @@ impl PlumeQuery {
|
||||||
// if at least one range bound is provided
|
// if at least one range bound is provided
|
||||||
let after = self
|
let after = self
|
||||||
.after
|
.after
|
||||||
.unwrap_or_else(|| i64::from(NaiveDate::from_ymd(2000, 1, 1).num_days_from_ce()));
|
.unwrap_or_else(|| i64::from(NaiveDate::from_ymd_opt(2000, 1, 1).unwrap().num_days_from_ce()));
|
||||||
let before = self
|
let before = self
|
||||||
.before
|
.before
|
||||||
.unwrap_or_else(|| i64::from(Utc::today().num_days_from_ce()));
|
.unwrap_or_else(|| i64::from(Utc::now().date_naive().num_days_from_ce()));
|
||||||
let field = Searcher::schema().get_field("creation_date").unwrap();
|
let field = Searcher::schema().get_field("creation_date").unwrap();
|
||||||
let range =
|
let range =
|
||||||
RangeQuery::new_i64_bounds(field, Bound::Included(after), Bound::Included(before));
|
RangeQuery::new_i64_bounds(field, Bound::Included(after), Bound::Included(before));
|
||||||
|
@ -202,7 +202,7 @@ impl PlumeQuery {
|
||||||
pub fn before<D: Datelike>(&mut self, date: &D) -> &mut Self {
|
pub fn before<D: Datelike>(&mut self, date: &D) -> &mut Self {
|
||||||
let before = self
|
let before = self
|
||||||
.before
|
.before
|
||||||
.unwrap_or_else(|| i64::from(Utc::today().num_days_from_ce()));
|
.unwrap_or_else(|| i64::from(Utc::now().date_naive().num_days_from_ce()));
|
||||||
self.before = Some(cmp::min(before, i64::from(date.num_days_from_ce())));
|
self.before = Some(cmp::min(before, i64::from(date.num_days_from_ce())));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ impl PlumeQuery {
|
||||||
pub fn after<D: Datelike>(&mut self, date: &D) -> &mut Self {
|
pub fn after<D: Datelike>(&mut self, date: &D) -> &mut Self {
|
||||||
let after = self
|
let after = self
|
||||||
.after
|
.after
|
||||||
.unwrap_or_else(|| i64::from(NaiveDate::from_ymd(2000, 1, 1).num_days_from_ce()));
|
.unwrap_or_else(|| i64::from(NaiveDate::from_ymd_opt(2000, 1, 1).unwrap().num_days_from_ce()));
|
||||||
self.after = Some(cmp::max(after, i64::from(date.num_days_from_ce())));
|
self.after = Some(cmp::max(after, i64::from(date.num_days_from_ce())));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub fn search(query: Option<Form<SearchQuery>>, conn: DbConn, rockets: PlumeRock
|
||||||
if str_query.is_empty() {
|
if str_query.is_empty() {
|
||||||
render!(search::index(
|
render!(search::index(
|
||||||
&(&conn, &rockets).to_context(),
|
&(&conn, &rockets).to_context(),
|
||||||
&format!("{}", Utc::today().format("%Y-%m-d"))
|
&format!("{}", Utc::now().date_naive().format("%Y-%m-d"))
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
let res = rockets
|
let res = rockets
|
||||||
|
|
Loading…
Reference in a new issue