Permalink
Browse files

Fix task status reporting

  • Loading branch information...
1 parent 3ed1414 commit 4f570aaca4a733d09540d6ac61c818038fc1bbb0 Bob Dionne committed Feb 26, 2012
Showing with 15 additions and 3 deletions.
  1. +15 −3 apps/couch/src/couch_view_updater.erl
@@ -73,19 +73,31 @@ update(Owner, Group, #db{name = DbName} = Db) ->
_ -> [conflicts, deleted_conflicts]
end,
EnumFun = fun ?MODULE:load_docs/3,
- Acc0 = {0, Db, MapQueue, DocOpts, IncludeDesign, TotalChanges},
+ Acc0 = {0, Db, MapQueue, DocOpts, IncludeDesign},
{ok, _, _} = couch_db:enum_docs_since(Db, Seq, EnumFun, Acc0, []),
couch_work_queue:close(MapQueue),
receive {new_group, NewGroup} ->
exit({new_group,
NewGroup#group{current_seq=couch_db:get_update_seq(Db)}})
end.
-load_docs(DocInfo, _, {I, Db, MapQueue, DocOpts, IncludeDesign, Total} = Acc) ->
- couch_task_status:update([{progress, I}, {changes_done, Total}]),
+load_docs(DocInfo, _, {I, Db, MapQueue, DocOpts, IncludeDesign} = Acc) ->
+ update_task(I),
load_doc(Db, DocInfo, MapQueue, DocOpts, IncludeDesign),
{ok, setelement(1, Acc, I+1)}.
+update_task(NumChanges) ->
+ [Changes, Total] = couch_task_status:get([changes_done, total_changes]),
+ Changes2 = Changes + NumChanges,
+ Progress = case Total of
+ 0 ->
+ 0;
+ _ ->
+ (Changes2 * 100) div Total
+ end,
+ couch_task_status:update([{progress, Progress}, {changes_done, Changes2}]).
+
+
purge_index(#group{views=Views, id_btree=IdBtree}=Group, Db) ->
{ok, PurgedIdsRevs} = couch_db:get_last_purged(Db),
Ids = [Id || {Id, _Revs} <- PurgedIdsRevs],

0 comments on commit 4f570aa

Please sign in to comment.