Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

Commit

Permalink
Display in-memory data as soon as available
Browse files Browse the repository at this point in the history
  • Loading branch information
swaroopch committed Jul 28, 2013
1 parent 511bdda commit 33d733c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
14 changes: 8 additions & 6 deletions resources/book.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
{{/binding}}
{{/info}}
</dl>
{{^price}}
{{^pricePresent}}
<p><em>Fetching info and prices... page will refresh automatically.</em></p>
<script type="text/javascript">
window.onload = function() {
setTimeout("window.location.reload(true)", 20 * 1000);
};
</script>
{{/price}}
{{/pricePresent}}
</div>
<div class="span4">
{{#info}}
Expand All @@ -67,25 +67,27 @@
</div>
</div>

{{#price}}
{{#pricePresent}}
<div class="container-fluid">
<div class="row-fluid">
<div class="span4 offset2">
<h3>Prices</h3>
<table class="table table-bordered table-hover">
{{#price}}
<tr>
{{#url}}
<th><a href="{{url}}">{{name}}</a></th>
{{/url}}
{{^url}}
<th>{{name}}</th>
{{/url}}
<td>{{amount}}</td>
</tr>
<td>{{amount}}</td>
</tr>
{{/price}}
</table>
</div>
</div>
</div>
{{/price}}
{{/pricePresent}}

{{>footer}}
12 changes: 7 additions & 5 deletions src/isbnnetinclj2/store.clj
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,11 @@

(defn book-data
[isbn]
(or (mongo/get-recent-entry isbn)
(do
(future (fetch-all-stores isbn))
{:when (time/now)})))
(or (get @book-data-cache isbn)
(or (mongo/get-recent-entry isbn)
(do
(future (fetch-all-stores isbn))
{:when (time/now)}))))


(defn book-page
Expand All @@ -294,7 +295,8 @@
"book"
(merge
data
{:isbn isbn
{:pricePresent (> (count price) 0)
:isbn isbn
:pageTitle (or (get-in data [:info :title])
isbn)
:price price}))))
Expand Down

0 comments on commit 33d733c

Please sign in to comment.