Skip to content

Commit

Permalink
Open data seems to be returning 404 errors now. Data coming from the …
Browse files Browse the repository at this point in the history
…resources was very inaccurate for today's commute anyways. Handle 4xx errors. THrew insSome timimg updates and search filters.
  • Loading branch information
ashafa committed Apr 6, 2012
1 parent 252ae95 commit 461413f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/cljs/server/wheresthembta/real_time_feed.cljs
Expand Up @@ -31,7 +31,8 @@
(doseq [waiter @waiters] (waiter %))
(reset! waiters []))
rest (-> (.get restler real-time-feed-url)
(.on "complete" #(set-cache (js->clj (.parse js/JSON %) :keywordize-keys true)))
(.on "2xx" #(set-cache (js->clj (.parse js/JSON %) :keywordize-keys true)))
(.on "4xx" #(set-cache (or data [])))
(.on "error" #(set-cache (or data []))))]
(reset! timeout (js/setTimeout #(.. rest -request (abort "timeout")) 2000)))))))
(callback req res [])))))
8 changes: 4 additions & 4 deletions src/cljs/shared/mbta_data.cljs
Expand Up @@ -160,7 +160,7 @@
:title "Malden Center"
:platform-keys #{"OMALN" "OMALS"}
:location [-71.07433 42.42723]
:search-for [#"(?i)\bmalden(\W*cen.*)?\b"]
:search-for [#"(?i)\bmalden\W*c[ent]\w*\b"]
:search-not []}
{:id "wellington"
:title "Wellington"
Expand Down Expand Up @@ -197,7 +197,7 @@
:platform-keys #{"OSTSN" "OSTSS"}
:location [-71.057717 42.358675]
:search-for [#"(?i)state\W?st\W" #"(?i)\bat state\b" #"(?i)\bto state\b" #"(?i)\bin state\b" #"(?i)\bfrom state\b"]
:search-not []}
:search-not [#"(?i)\bstate\W*house\b"]}
{:id "downtown-crossing"
:title "Downtown Crossing - Orange Line"
:platform-keys #{"ODTSN" "ODTSS"}
Expand Down Expand Up @@ -316,7 +316,7 @@
:title "Maverick"
:platform-keys #{"BMAVE" "BMAVW"}
:location [-71.039212 42.368719]
:search-for [#"(?i)maverick"]
:search-for [#"(?i)\bmaverick\b"]
:search-not []}
{:id "aquarium"
:title "Aquarium"
Expand All @@ -329,7 +329,7 @@
:platform-keys #{"BSTAE" "BSTAW"}
:location [-71.057708 42.358617]
:search-for [#"(?i)(\W|^)state\W*st\W" #"(?i)\bat state\b" #"(?i)\bto state\b" #"(?i)\bin state\b" #"(?i)\bfrom state\b"]
:search-not []}
:search-not [#"(?i)\bstate\W*house\b"]}
{:id "government-center"
:title "Government Center"
:platform-keys #{"BGOVE" "BGOVW"}
Expand Down
12 changes: 6 additions & 6 deletions src/cljs/shared/templates.cljs
Expand Up @@ -65,12 +65,12 @@
time-str (utils/format-seconds seconds)
time-html (if is-reverse?
(cond (= seconds 0) [:li {:class (str revenue " refresh")} time-str]
(< seconds 25) [:li {:class revenue} "Approaching"]
(= seconds 25) [:li {:class (str revenue " refresh")} "Approaching"]
(< seconds 50) [:li {:class revenue} "Arriving"]
(= seconds 50) [:li {:class (str revenue " refresh")} "Arriving"]
(< seconds 80) [:li {:class revenue} "Departing"]
(= seconds 80) [:li {:class (str revenue " refresh")} "Departing"])
(< seconds 20) [:li {:class revenue} "Approaching"]
(= seconds 20) [:li {:class (str revenue " refresh")} "Approaching"]
(< seconds 40) [:li {:class revenue} "Arriving"]
(= seconds 40) [:li {:class (str revenue " refresh")} "Arriving"]
(< seconds 70) [:li {:class revenue} "Departing"]
(= seconds 70) [:li {:class (str revenue " refresh")} "Departing"])
[:li time-str])]
time-html))))]])])])

Expand Down

0 comments on commit 461413f

Please sign in to comment.