<commit_before>module Api
  module V0
    class GuidanceGroupsController  < Api::V0::BaseController
      before_action :authenticate

      swagger_controller :guidance_groupss, 'Guidance Groups'

      swagger_api :show do
        summary 'Returns a single guidance group item'
        notes   'Notes...'
        param :path, :id, :integer, :required, "Guidance Group Id"
        param :header, 'Authorization Token', :string, :required, 'Authorization-Token'
        response :ok, "success", :Guidance
        response :unauthorized
        response :not_found
      end

      # TODO: impliment auth on show/index
      # for both, first validate that the user has the permission to use this api
      # then for show, display iff they have permissions for that resource
      # for index, compile the list of all groups they have permissions to view, then return

      def show
        # check if the user has permission to use the guidances api
        if has_auth("guidance")
          # determine if they have authorization to view this guidance group
          if GuidanceGroup.can_view(@user, params[:id])
            respond_with get_resource
          else
            render json: I18n.t("api.bad_resource"), status: 401
          end
        else
          render json: I18n.t("api.no_auth_for_endpoint"), status: 401
        end
      end

      swagger_api :index do
        summary 'Returns a list of all viewable guidances'
        notes   'Notes...'
        param :header, 'Authentication-Token', :string, :required, 'Authentication-Token'
        response :unauthorized
      end


      def index

        if has_auth("guidance")<commit_msg>changed can_view to can_view? for consistency<commit_after>module Api
  module V0
    class GuidanceGroupsController  < Api::V0::BaseController
      before_action :authenticate

      swagger_controller :guidance_groupss, 'Guidance Groups'

      swagger_api :show do
        summary 'Returns a single guidance group item'
        notes   'Notes...'
        param :path, :id, :integer, :required, "Guidance Group Id"
        param :header, 'Authorization Token', :string, :required, 'Authorization-Token'
        response :ok, "success", :Guidance
        response :unauthorized
        response :not_found
      end

      # TODO: impliment auth on show/index
      # for both, first validate that the user has the permission to use this api
      # then for show, display iff they have permissions for that resource
      # for index, compile the list of all groups they have permissions to view, then return

      def show
        # check if the user has permission to use the guidances api
        if has_auth("guidance")
          # determine if they have authorization to view this guidance group
          if GuidanceGroup.can_view?(@user, params[:id])
            respond_with get_resource
          else
            render json: I18n.t("api.bad_resource"), status: 401
          end
        else
          render json: I18n.t("api.no_auth_for_endpoint"), status: 401
        end
      end

      swagger_api :index do
        summary 'Returns a list of all viewable guidances'
        notes   'Notes...'
        param :header, 'Authentication-Token', :string, :required, 'Authentication-Token'
        response :unauthorized
      end


      def index

        if has_auth("guidance")
{'fraction_non_alphanumeric': 0.0714498362607919, 'fraction_numerical': 0.00714498362607919, 'mean_word_length': 2.442622950819672, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5390583', 'n_tokens_mistral': 900, 'n_tokens_neox': 859, 'n_words': 334}