A few updates.

This commit is contained in:
Elf M. Sternberg 2016-02-08 15:09:08 -08:00
parent dd91a3cb85
commit 1ab5bb05fd
5 changed files with 43 additions and 25 deletions

View File

@ -2,7 +2,9 @@
(import [flask [Flask]])
(def app (Flask __name__))
(def hello ((.route app "/") (fn [] "Hello World")))
(with-decorator (.route app "/") (defn hello [] "Hello World"))
(if (= __name__ "__main__")
(.run app))

View File

@ -1,4 +1,3 @@
# from http://flask.pocoo.org/ tutorial
from flask import Flask
app = Flask(__name__)

View File

@ -15,6 +15,14 @@ Note: "BS" stands for BrainStorming.
slot is booked, other clients should not be able to book that slot
with the same coach.
## Alternatives
Google Calendar offers an "office hours" appointment mechanism. It
doesn't quite do what the problem requires; it's only available to
other members of the same school or corporate group account.
## Solution requirements:
* Data Store
@ -175,6 +183,11 @@ TODO Postgres range example
TODO Deliver home page
TODO Deliver retreivals
---
Quick thoughts:
Craft views or

View File

@ -1,4 +1,5 @@
Re-learning how to install Postgres (*Sigh)
# Re-learning how to install Postgres (*Sigh)
## WITH Postgres 9.4
CREATE DATABASE officehours;
CREATE USER officehours;
@ -16,17 +17,15 @@ CREATE EXTENSION citext;
CREATE EXTENSION btree_gist;
CREATE EXTENSION plv8;
#
What can I do?
1) Add users and make them clients.
2) Add users and make them staff.
3) Allocate a block of time as "office hours"
4) Allocate a block of time as an "appointment."
NEXT: Psycopg2
# What can I do?
** Progress: Everything works in psycopg2 EXCEPT add_appointment, which
is very distressing. Really, _really_ don't want to take that
functionality and put it into the middle tier. It's rock-solid business
logic; it belongs in the database as a constraint.
1) Add users and make them clients.
2) Add users and make them staff.
3) Allocate a block of time as "office hours"
4) Allocate a block of time as an "appointment."
## Progress:
Everything works in psycopg2.

21
play.hy
View File

@ -7,7 +7,6 @@
(defn connect []
(psycopg2.connect "host='localhost' dbname='officehours' user='officehours' password='eatabug'"))
(def users [
(, "Alice" "alice@example.com")
(, "Bob" "bob@example.com")
@ -58,16 +57,22 @@
(.execute curs "INSERT INTO officehours (staff_id, during) VALUES (2, '[2015-02-07 12:00, 2015-02-07 15:00)');")
(.commit conn))
; [ops ["SELECT add_appointment(3, '[2015-02-07 10:00, 2015-02-07 10:30)');"
; "SELECT add_appointment(4, '[2015-02-07 10:30, 2015-02-07 11:00)');"
; "SELECT add_appointment(5, '[2015-02-07 13:00, 2015-02-07 13:30)');"
; "SELECT add_appointment(6, '[2015-02-07 13:30, 2015-02-07 14:00)');"]]]
(let [[conn (connect)]
[curs (.cursor conn)]
[ops ["SELECT add_appointment(3, '[2015-02-07 10:00, 2015-02-07 10:30)');"
"SELECT add_appointment(4, '[2015-02-07 10:30, 2015-02-07 11:00)');"
"SELECT add_appointment(5, '[2015-02-07 13:00, 2015-02-07 13:30)');"
"SELECT add_appointment(6, '[2015-02-07 13:30, 2015-02-07 14:00)');"]]]
[ops [(, 3 "[2015-02-07 10:00, 2015-02-07 10:30)")
(, 4 "[2015-02-07 10:30, 2015-02-07 11:00)")
(, 5 "[2015-02-07 13:00, 2015-02-07 13:30)")
(, 6 "[2015-02-07 13:30, 2015-02-07 14:00)")]]]
(for [op ops]
(print op)
(.execute curs op)
(.callproc curs "add_appointment" op)
(.commit conn)))
(let [[conn (connect)]