<commit_before>%% @author Couchbase <<EMAIL>>
%% @copyright 2011 Couchbase, Inc.
%%
%% 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(capi_frontend).

-compile(export_all).

-include("couch_db.hrl").
-include_lib("couch_index_merger/include/couch_index_merger.hrl").
-include_lib("couch_index_merger/include/couch_view_merger.hrl").
-include("ns_common.hrl").
-include("mc_entry.hrl").
-include("mc_constants.hrl").

-record(collect_acc, {
          row_count = undefined,
          rows = []
         }).


not_implemented(Arg, Rest) ->
    {not_implemented, Arg, Rest}.

do_db_req(#httpd{path_parts=[<<"_replicator">>|_]}=Req, Fun) ->
    %% TODO: AUTH!!!!
    couch_db_frontend:do_db_req(Req, Fun);
do_db_req(#httpd{mochi_req=MochiReq, user_ctx=UserCtx,
                 path_parts=[DbName | RestPathParts]} = Req, Fun) ->

    % check auth here
    [BucketName | AfterSlash] = binary:split(DbName, <<"/">>),
    ListBucketName = ?b2l(BucketName),
    BucketConfig = case ns_bucket:get_bucket_light(ListBucketName) of
                      not_present ->
                           throw({not_found, missing});
                      {ok, X} -> X
                  end,<commit_msg>CBD-92: disable capi unless cluster compat is 2.0<commit_after>%% @author Couchbase <<EMAIL>>
%% @copyright 2011 Couchbase, Inc.
%%
%% 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(capi_frontend).

-compile(export_all).

-include("couch_db.hrl").
-include_lib("couch_index_merger/include/couch_index_merger.hrl").
-include_lib("couch_index_merger/include/couch_view_merger.hrl").
-include("ns_common.hrl").
-include("mc_entry.hrl").
-include("mc_constants.hrl").

-record(collect_acc, {
          row_count = undefined,
          rows = []
         }).


not_implemented(Arg, Rest) ->
    {not_implemented, Arg, Rest}.

do_db_req(#httpd{path_parts=[<<"_replicator">>|_]}=Req, Fun) ->
    %% TODO: AUTH!!!!
    couch_db_frontend:do_db_req(Req, Fun);
do_db_req(#httpd{mochi_req=MochiReq, user_ctx=UserCtx,
                 path_parts=[DbName | RestPathParts]} = Req, Fun) ->
    %% it'll just crash if somebody wants to access CAPI in older
    %% compat mode
    true = cluster_compat_mode:is_cluster_20(),

    % check auth here
    [BucketName | AfterSlash] = binary:split(DbName, <<"/">>),
    ListBucketName = ?b2l(BucketName),
    BucketConfig = case ns_bucket:get_bucket_light(ListBucketName) of
                      not_present ->
                           throw({not_found, missing});
                      {ok, X} -> X
                  end,
{'fraction_non_alphanumeric': 0.1319697394228075, 'fraction_numerical': 0.0067245727094424204, 'mean_word_length': 3.3643031784841075, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, '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': '2187116', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1115, 'n_words': 289}