<commit_before>% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License.  You may obtain a copy of
% the License at
%
%   http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
% License for the specific language governing permissions and limitations under
% the License.

-module(couch_doc).

-export([get_view_functions/1, is_special_doc/1,to_doc_info/1]).
-export([bin_foldl/3,bin_size/1,bin_to_binary/1]).
-export([from_json_obj/1,to_json_obj/2,has_stubs/1, merge_stubs/2]).

-include("couch_db.hrl").

to_json_obj(#doc{id=Id,deleted=Del,body=Body,revs=Revs,meta=Meta}=Doc,Options)->
    {[{<<"_id">>, Id}] ++
        case Revs of
        [] -> [];
        _ -> [{<<"_rev">>, lists:nth(1, Revs)}]
        end ++
        case Del of
        false ->
            {BodyProps} = Body,
            BodyProps;
        true ->
            [{<<"_deleted">>, true}]
        end ++
        case lists:member(revs, Options) of
        false -> [];
        true ->
            [{<<"_revs">>, Revs}]
        end ++
        lists:map(
            fun({revs_info, RevsInfo}) ->
                JsonRevsInfo =
                [{[{rev, Rev}, {status, atom_to_list(Status)}]} ||
                    {Rev, Status} <- RevsInfo],
                {<<"_revs_info">>, JsonRevsInfo};
            ({conflicts, Conflicts}) ->
                {<<"_conflicts">>, Conflicts};
            ({deleted_conflicts, Conflicts}) -><commit_msg>fixed JSON regression about revs_info status<commit_after>% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License.  You may obtain a copy of
% the License at
%
%   http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
% License for the specific language governing permissions and limitations under
% the License.

-module(couch_doc).

-export([get_view_functions/1, is_special_doc/1,to_doc_info/1]).
-export([bin_foldl/3,bin_size/1,bin_to_binary/1]).
-export([from_json_obj/1,to_json_obj/2,has_stubs/1, merge_stubs/2]).

-include("couch_db.hrl").

to_json_obj(#doc{id=Id,deleted=Del,body=Body,revs=Revs,meta=Meta}=Doc,Options)->
    {[{<<"_id">>, Id}] ++
        case Revs of
        [] -> [];
        _ -> [{<<"_rev">>, lists:nth(1, Revs)}]
        end ++
        case Del of
        false ->
            {BodyProps} = Body,
            BodyProps;
        true ->
            [{<<"_deleted">>, true}]
        end ++
        case lists:member(revs, Options) of
        false -> [];
        true ->
            [{<<"_revs">>, Revs}]
        end ++
        lists:map(
            fun({revs_info, RevsInfo}) ->
                JsonRevsInfo =
                [{[{rev, Rev}, {status, list_to_binary(atom_to_list(Status))}]} ||
                    {Rev, Status} <- RevsInfo],
                {<<"_revs_info">>, JsonRevsInfo};
            ({conflicts, Conflicts}) ->
                {<<"_conflicts">>, Conflicts};
            ({deleted_conflicts, Conflicts}) ->
{'fraction_non_alphanumeric': 0.14888048851410293, 'fraction_numerical': 0.008723466123873218, 'mean_word_length': 2.467741935483871, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5779780', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1067, 'n_words': 275}