summaryrefslogtreecommitdiff
path: root/help/app/models
diff options
context:
space:
mode:
authorjessib <jessib@leap.se>2012-12-07 15:38:23 -0800
committerjessib <jessib@leap.se>2012-12-07 15:38:23 -0800
commit7a9a4f4e7bd090fd27e05b03f93832d79f5f8db2 (patch)
treee8bd8cdfb989f4add5898034f781f6c16c5109b7 /help/app/models
parent7aa25d0f9b184b81bf976a2b77c026f2b8b28f73 (diff)
Added reduce functions, so pagination should now work correctly. This also removes the need for .all call in some tests.
Diffstat (limited to 'help/app/models')
-rw-r--r--help/app/models/ticket.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/help/app/models/ticket.rb b/help/app/models/ticket.rb
index f9852a4..cd4fcfb 100644
--- a/help/app/models/ticket.rb
+++ b/help/app/models/ticket.rb
@@ -56,11 +56,11 @@ class Ticket < CouchRest::Model::Base
if (comment.posted_by && !arr[comment.posted_by]) {
//don't add duplicates
arr[comment.posted_by] = true;
- emit(comment.posted_by, doc);
+ emit(comment.posted_by, 1);
}
});
}
- }"
+ }", :reduce => "function(k,v,r) { return sum(v); }"
view :includes_post_by_and_open_status_and_updated_at,
:map =>
@@ -71,12 +71,11 @@ class Ticket < CouchRest::Model::Base
if (comment.posted_by && !arr[comment.posted_by]) {
//don't add duplicates
arr[comment.posted_by] = true;
- emit([comment.posted_by, doc.is_open, doc.updated_at], doc);
+ emit([comment.posted_by, doc.is_open, doc.updated_at], 1);
}
});
}
- }"
-
+ }", :reduce => "function(k,v,r) { return sum(v); }"
view :includes_post_by_and_open_status_and_created_at,
:map =>
@@ -87,11 +86,11 @@ class Ticket < CouchRest::Model::Base
if (comment.posted_by && !arr[comment.posted_by]) {
//don't add duplicates
arr[comment.posted_by] = true;
- emit([comment.posted_by, doc.is_open, doc.created_at], doc);
+ emit([comment.posted_by, doc.is_open, doc.created_at], 1);
}
});
}
- }"
+ }", :reduce => "function(k,v,r) { return sum(v); }"
view :includes_post_by_and_updated_at,
:map =>
@@ -102,11 +101,11 @@ class Ticket < CouchRest::Model::Base
if (comment.posted_by && !arr[comment.posted_by]) {
//don't add duplicates
arr[comment.posted_by] = true;
- emit([comment.posted_by, doc.updated_at], doc);
+ emit([comment.posted_by, doc.updated_at], 1);
}
});
}
- }"
+ }", :reduce => "function(k,v,r) { return sum(v); }"
view :includes_post_by_and_created_at,
@@ -118,11 +117,11 @@ class Ticket < CouchRest::Model::Base
if (comment.posted_by && !arr[comment.posted_by]) {
//don't add duplicates
arr[comment.posted_by] = true;
- emit([comment.posted_by, doc.created_at], doc);
+ emit([comment.posted_by, doc.created_at], 1);
}
});
}
- }"
+ }", :reduce => "function(k,v,r) { return sum(v); }"
end