Permalink
Browse files

Db declaration + print 50 results by arrondissement + order by score

  • Loading branch information...
1 parent 3cc9a6e commit e2752d7c05664a0b95db454f374168ef3e09a7d6 @cedricss committed Mar 21, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/main.opa
View
@@ -12,6 +12,19 @@ type result = {
int score,
}
+database presidential @mongo {
+ result /first[{id}]
+}
+
+function table(arr) {
+ dbset(result, _) s = /presidential/first[arrondissement == arr; order -score; limit 50];
+ it = DbSet.iterator(s);
+ Iter.fold(
+ function(r, acc) { [table_row(r) | acc] },
+ it, []
+ ) |> List.rev;
+}
+
function table_row(result) {
<tr>
<td>{ result.id }</td>
@@ -29,7 +42,7 @@ function tab_pan(arr) {
<div class="tab-pane" id="a{arr}">
<table class="table table-striped table-condensed">
<thead><td>Id</td><td>Bureau de vote</td><td>Candidat</td><td>Score</td><td>Action</td><td>Nb log</td></thead>
- <tbody></tbody>
+ <tbody>{ table(arr) }</tbody>
</table>
</div>
}

0 comments on commit e2752d7

Please sign in to comment.