<commit_before># Copyright (C) 2012-2015 Zammad Foundation, http://zammad-foundation.org/

require 'icalendar'

class IcalTicketsController < ApplicationController
  before_action { authentication_check( { basic_auth_promt: true, token_action: 'iCal' } ) }

  # @path       [GET] /ical/tickets
  #
  # @summary          Returns an iCal file with all tickets (open, new, pending, esclation) as events.
  #
  # @parameter        action_token(required) [String] The action_token identifying the requested User privileged for 'iCal' action.
  #
  # @response_message 200 [String] iCal file ready to import in calendar applications.
  # @response_message 401          Permission denied.
  def all
    new_open_events_data   = new_open_events_data_get
    pending_events_data    = pending_events_data_get
    escalation_events_data = escalation_events_data_get

    events_data = new_open_events_data + pending_events_data + escalation_events_data

    events_data_to_ical( events_data )
  end

  # @path       [GET] /ical/tickets_new_open
  #
  # @summary          Returns an iCal file with all new and open tickets as events.
  #
  # @parameter        action_token(required) [String] The action_token identifying the requested User privileged for 'iCal' action.
  #
  # @response_message 200 [String] iCal file ready to import in calendar applications.
  # @response_message 401          Permission denied.
  def new_open
    events_data = new_open_events_data_get

    events_data_to_ical( events_data )
  end

  # @path       [GET] /ical/tickets_pending
  #
  # @summary          Returns an iCal file with all pending tickets as events.
  #
  # @parameter        action_token(required) [String] The action_token identifying the requested User privileged for 'iCal' action.
  #
  # @response_message 200 [String] iCal file ready to import in calendar applications.
  # @response_message 401          Permission denied.
  def pending
    events_data = pending_events_data_get

    events_data_to_ical( events_data )
  end

  # @path       [GET] /ical/ticket_escalation
  #
  # @summary          Returns an iCal file with all escalation times for tickets as events.
  #
  # @parameter        action_token(required) [String] The action_token identifying the requested User privileged for 'iCal' action.
  #
  # @response_message 200 [String] iCal file ready to import in calendar applications.
  # @response_message 401          Permission denied.
  def escalation
    events_data = escalation_events_data_get

    events_data_to_ical( events_data )
  end

  private

  def new_open_events_data_get

    condition = {
      'tickets.owner_id' => current_user.id,
      'tickets.state_id' => Ticket::State.where(
        state_type_id: Ticket::StateType.where(
          name: %w(new open),
        ),
      ),
    }

    tickets = Ticket.search(
      current_user: current_user,
      condition: condition,
    )

    events_data = []
    tickets.each do |ticket|

      event_data = {}<commit_msg>Removed wrong documentation.<commit_after># Copyright (C) 2012-2015 Zammad Foundation, http://zammad-foundation.org/

require 'icalendar'

class IcalTicketsController < ApplicationController
  before_action { authentication_check( { basic_auth_promt: true, token_action: 'iCal' } ) }

  # @path       [GET] /ical/tickets
  #
  # @summary          Returns an iCal file with all tickets (open, new, pending, esclation) as events.
  #
  # @response_message 200 [String] iCal file ready to import in calendar applications.
  # @response_message 401          Permission denied.
  def all
    new_open_events_data   = new_open_events_data_get
    pending_events_data    = pending_events_data_get
    escalation_events_data = escalation_events_data_get

    events_data = new_open_events_data + pending_events_data + escalation_events_data

    events_data_to_ical( events_data )
  end

  # @path       [GET] /ical/tickets_new_open
  #
  # @summary          Returns an iCal file with all new and open tickets as events.
  #
  # @response_message 200 [String] iCal file ready to import in calendar applications.
  # @response_message 401          Permission denied.
  def new_open
    events_data = new_open_events_data_get

    events_data_to_ical( events_data )
  end

  # @path       [GET] /ical/tickets_pending
  #
  # @summary          Returns an iCal file with all pending tickets as events.
  #
  # @response_message 200 [String] iCal file ready to import in calendar applications.
  # @response_message 401          Permission denied.
  def pending
    events_data = pending_events_data_get

    events_data_to_ical( events_data )
  end

  # @path       [GET] /ical/ticket_escalation
  #
  # @summary          Returns an iCal file with all escalation times for tickets as events.
  #
  # @response_message 200 [String] iCal file ready to import in calendar applications.
  # @response_message 401          Permission denied.
  def escalation
    events_data = escalation_events_data_get

    events_data_to_ical( events_data )
  end

  private

  def new_open_events_data_get

    condition = {
      'tickets.owner_id' => current_user.id,
      'tickets.state_id' => Ticket::State.where(
        state_type_id: Ticket::StateType.where(
          name: %w(new open),
        ),
      ),
    }

    tickets = Ticket.search(
      current_user: current_user,
      condition: condition,
    )

    events_data = []
    tickets.each do |ticket|

      event_data = {}
{'fraction_non_alphanumeric': 0.0720175920835624, 'fraction_numerical': 0.011728055708264615, 'mean_word_length': 3.1161387631975868, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3005458', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1613, 'n_words': 456}