couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r981607 - in /couchdb/trunk: share/www/script/test/view_update_seq.js src/couchdb/couch_httpd_view.erl src/couchdb/couch_view.erl
Date Mon, 02 Aug 2010 17:33:59 GMT
Author: fdmanana
Date: Mon Aug  2 17:33:59 2010
New Revision: 981607

URL: http://svn.apache.org/viewvc?rev=981607&view=rev
Log:
Add option "stale=update_after" when querying a view. Closes COUCHDB-837.

Modified:
    couchdb/trunk/share/www/script/test/view_update_seq.js
    couchdb/trunk/src/couchdb/couch_httpd_view.erl
    couchdb/trunk/src/couchdb/couch_view.erl

Modified: couchdb/trunk/share/www/script/test/view_update_seq.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/view_update_seq.js?rev=981607&r1=981606&r2=981607&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/view_update_seq.js (original)
+++ couchdb/trunk/share/www/script/test/view_update_seq.js Mon Aug  2 17:33:59 2010
@@ -68,17 +68,23 @@ couchTests.view_update_seq = function(de
   T(resp.rows.length == 1);
   T(resp.update_seq == 101);
 
+  db.save({"id":"00"});
+  resp = db.view('test/all_docs',
+    {limit: 1, stale: "update_after", update_seq: true});
+  T(resp.rows.length == 1);
+  T(resp.update_seq == 101);
+
   resp = db.view('test/all_docs', {limit: 1, update_seq:true});
   T(resp.rows.length == 1);
-  T(resp.update_seq == 102);
+  T(resp.update_seq == 103);
 
   resp = db.view('test/all_docs',{update_seq:true},["0","1"]);
-  T(resp.update_seq == 102);
+  T(resp.update_seq == 103);
 
   resp = db.view('test/all_docs',{update_seq:true},["0","1"]);
-  T(resp.update_seq == 102);
+  T(resp.update_seq == 103);
 
   resp = db.view('test/summate',{group:true, update_seq:true},["0","1"]);
-  T(resp.update_seq == 102);
+  T(resp.update_seq == 103);
 
 };

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=981607&r1=981606&r2=981607&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Mon Aug  2 17:33:59 2010
@@ -282,8 +282,11 @@ parse_view_param("count", _Value) ->
     throw({query_parse_error, <<"Query parameter 'count' is now 'limit'.">>});
 parse_view_param("stale", "ok") ->
     [{stale, ok}];
+parse_view_param("stale", "update_after") ->
+    [{stale, update_after}];
 parse_view_param("stale", _Value) ->
-    throw({query_parse_error, <<"stale only available as stale=ok">>});
+    throw({query_parse_error,
+            <<"stale only available as stale=ok or as stale=update_after">>});
 parse_view_param("update", _Value) ->
     throw({query_parse_error, <<"update=false is now stale=ok">>});
 parse_view_param("descending", Value) ->

Modified: couchdb/trunk/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_view.erl?rev=981607&r1=981606&r2=981607&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_view.erl Mon Aug  2 17:33:59 2010
@@ -58,11 +58,23 @@ get_group_server(DbName, GroupId) ->
 get_group(Db, GroupId, Stale) ->
     MinUpdateSeq = case Stale of
     ok -> 0;
+    update_after -> 0;
     _Else -> couch_db:get_update_seq(Db)
     end,
-    couch_view_group:request_group(
+    Result = {ok, Group} = couch_view_group:request_group(
             get_group_server(couch_db:name(Db), GroupId),
-            MinUpdateSeq).
+            MinUpdateSeq),
+    case Stale of
+    update_after ->
+        % best effort, process might die
+        spawn(fun() ->
+            LastSeq = couch_db:get_update_seq(Db),
+            couch_view_group:request_group(Group, LastSeq)
+        end);
+    _ ->
+        ok
+    end,
+    Result.
 
 get_temp_group(Db, Language, DesignOptions, MapSrc, RedSrc) ->
     couch_view_group:request_group(



Mime
View raw message