ticker-serve: select starting today
This commit is contained in:
rodič
a9ed009cad
revize
72349760eb
|
@ -1706,6 +1706,7 @@ dependencies = [
|
|||
name = "ticker-serve"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libticker 0.1.0",
|
||||
"rocket 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -22,3 +22,4 @@ CREATE TABLE events (
|
|||
location TEXT,
|
||||
url TEXT
|
||||
);
|
||||
CREATE index events_dtstart_dtend ON events (dtstart, dtend);
|
||||
|
|
|
@ -8,4 +8,5 @@ edition = "2018"
|
|||
rocket = "0.4"
|
||||
typed-html = "0.2"
|
||||
diesel = { version = "~1", features = ["postgres", "chrono"] }
|
||||
chrono = "~0.4"
|
||||
libticker = { path = "../libticker" }
|
||||
|
|
|
@ -7,6 +7,7 @@ use std::sync::Mutex;
|
|||
use rocket::{State, response::content};
|
||||
use typed_html::{html, text, dom::DOMTree};
|
||||
use diesel::{Connection, pg::PgConnection, prelude::*};
|
||||
use chrono::offset::Local;
|
||||
|
||||
use libticker::{
|
||||
config::{Config, CalendarOptions},
|
||||
|
@ -26,7 +27,9 @@ fn fix_url(s: &str) -> std::borrow::Cow<str> {
|
|||
#[get("/")]
|
||||
fn index(db: State<Mutex<PgConnection>>) -> content::Html<String> {
|
||||
let db = db.lock().unwrap();
|
||||
let today = Local::today().naive_local().and_hms(0, 0, 0);
|
||||
let es = events
|
||||
.filter(schema::events::dtstart.ge(&today))
|
||||
.order_by(schema::events::dtstart.asc())
|
||||
.then_order_by(schema::events::dtend.desc())
|
||||
.load::<Event>(&*db)
|
||||
|
|
Načítá se…
Odkázat v novém úkolu