Skip to content

Commit

Permalink
Score booster added + log
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricss committed Mar 21, 2012
1 parent e2752d7 commit 592a50f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main.opa
Expand Up @@ -10,12 +10,20 @@ type result = {
string candidate_name,
string candidate_first_name,
int score,
list(Date.date) log
}

database presidential @mongo {
result /first[{id}]
}

function increase(result) {
/presidential/first[id == result.id] <- { score += 800, log <+ Date.now() };
arr = result.arrondissement;
#{"a{arr}"} = tab_pan(arr);
}


function table(arr) {
dbset(result, _) s = /presidential/first[arrondissement == arr; order -score; limit 50];
it = DbSet.iterator(s);
Expand All @@ -32,9 +40,11 @@ function table_row(result) {
<td>{ result.candidate_name }</td>
<td>{ result.score }</td>
<td>
<a href="#" class="btn btn-mini"></a>
<a onclick={ function(_) { increase(result) } } href="#" class="btn btn-mini">
Booster
</a>
</td>
<td></td>
<td>{ List.length(result.log) }</td>
</tr>
}

Expand Down

0 comments on commit 592a50f

Please sign in to comment.