diff options
author | Damien F. Katz <damien@apache.org> | 2008-05-20 19:57:37 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2008-05-20 19:57:37 +0000 |
commit | 5da7c1a8ba70f41a8e92cb1efee1f6c6898a2901 (patch) | |
tree | e675679054d39391833d0eafeb7a2a5ebac03286 /src/couchdb/couch_view.erl | |
parent | 2178d96a2f5d2103676d0319c07d1f6bb904b97c (diff) |
Fixed design document view definitions to be consistent with temp views. Changed the name of the map(K,V) call in the javascript views to emit(K,V)
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@658405 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_view.erl')
-rw-r--r-- | src/couchdb/couch_view.erl | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl index 4f6a2f47..b14f4564 100644 --- a/src/couchdb/couch_view.erl +++ b/src/couchdb/couch_view.erl @@ -155,32 +155,26 @@ reduce_to_count(Reductions) -> design_doc_to_view_group(#doc{id=Id,body={obj, Fields}}) -> Language = proplists:get_value("language", Fields, "javascript"), {obj, RawViews} = proplists:get_value("views", Fields, {obj, []}), - - % extract the map/reduce views from the json fields and into lists - MapViewsRaw = [{Name, Src, nil} || {Name, Src} <- RawViews, is_list(Src)], - MapReduceViewsRaw = - [{Name, - proplists:get_value("map", MRFuns), - proplists:get_value("reduce", MRFuns)} - || {Name, {obj, MRFuns}} <- RawViews], % add the views to a dictionary object, with the map source as the key DictBySrc = lists:foldl( - fun({Name, MapSrc, RedSrc}, DictBySrcAcc) -> + fun({Name, {obj, MRFuns}}, DictBySrcAcc) -> + MapSrc = proplists:get_value("map", MRFuns), + RedSrc = proplists:get_value("reduce", MRFuns, null), View = case dict:find(MapSrc, DictBySrcAcc) of {ok, View0} -> View0; error -> #view{def=MapSrc} % create new view object end, View2 = - if RedSrc == nil -> + if RedSrc == null -> View#view{map_names=[Name|View#view.map_names]}; true -> View#view{reduce_funs=[{Name,RedSrc}|View#view.reduce_funs]} end, dict:store(MapSrc, View2, DictBySrcAcc) - end, dict:new(), MapViewsRaw ++ MapReduceViewsRaw), + end, dict:new(), RawViews), % number the views {Views, _N} = lists:mapfoldl( fun({_Src, View}, N) -> |