Browse files

Added schemas to find last error

  • Loading branch information...
jessitron committed Jan 17, 2015
1 parent ca03d37 commit 17357d55975021f008c54ff053ac119788ad7587
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/schema_mock/core.clj
@@ -5,6 +5,11 @@
(def conversion-period (time/days 1))
(defn conversion-period-for [order] (time/minus (:when order) conversion-period))
+(def Customer {:uuid s/Str})
+(def Order { :who Customer :when org.joda.time.DateTime :what s/Any})
+(def Click { :who Customer :when org.joda.time.DateTime })
+(def Conversion {:click Click :outcome Order})
(defn fetch-orders [start-date end-date]
;; go to the database and fetch orders between those datetimes
@@ -15,14 +20,15 @@
(declare notice-conversions)
-(defn calculate-conversions-since [start-date]
+(s/defn calculate-conversions-since :- [Conversion] [start-date]
(let [end-date (time/minus (time/now) (time/hours 1))
orders (fetch-orders start-date end-date)]
- (concat
+ (apply concat
(for [o orders]
(let [clicks (fetch-clicks (conversion-period-for o) (:when o) (:who o))]
(notice-conversions o clicks))))))
-(defn- notice-conversions [order clicks]
+(s/defn notice-conversions :- [Conversion] [order :- Order
+ clicks :- [Click]]
;; dummy implementation: stupid-easiest way to green
[{:click (first clicks) :outcome order}])

0 comments on commit 17357d5

Please sign in to comment.