<commit_before>module Api
  class NotificationsController < BaseController
    PAGE = 1
    PER_PAGE = 2

    before_action :authenticate_user!

    expose(:my_tutors) {
      UserTutor.where(user: current_user, status: :accepted)
    }

    expose(:tutor_ids) {
      User.where(role: [:tutor, :tutor_familiar]).pluck(:id)
    }

    expose(:tutor_requests) {
      current_user.tutor_requests_received.pending
    }

    expose(:pending_notifications) {
      Notification.where.not(id: ReadNotification.where(user_id: current_user.id).pluck(:notifications_id))
    }

    expose(:tutor_notifications) {
      pending_notifications.where(user: my_tutors.pluck(:tutor_id))
                           .where(client_id: nil)
    }

    expose(:my_notifications) {
      pending_notifications.where(client: current_user)
    }

    expose(:admin_notifications) {
      pending_notifications.where.not(user: my_tutors.pluck(:tutor_id))
                           .where(client_id: nil)
                           .where.not(user: tutor_ids)
    }

    expose(:total_user_notifications) {
      serialized_admin = serialize_notifications(
                            admin_notifications,
                            Api::GenericNotificationSerializer
                          ).as_json
      serialized_tutor_requests = serialize_notifications(
                            tutor_requests,
                            Api::UserTutorSerializer
                          ).as_json

      serialized_my_notifications = serialize_notifications(
                        my_notifications,
                        Api::GenericNotificationSerializer
                      ).as_json

      serialized_tutor_notifications = serialize_notifications(
                        tutor_notifications,
                        Api::GenericNotificationSerializer
                      ).as_json

      serialized_my_notifications +
      serialized_tutor_requests +
      serialized_admin +<commit_msg>comparate dates to return notifications admin<commit_after>module Api
  class NotificationsController < BaseController
    PAGE = 1
    PER_PAGE = 2

    before_action :authenticate_user!

    expose(:my_tutors) {
      UserTutor.where(user: current_user, status: :accepted)
    }

    expose(:tutor_ids) {
      User.where(role: [:tutor, :tutor_familiar]).pluck(:id)
    }

    expose(:tutor_requests) {
      current_user.tutor_requests_received.pending
    }

    expose(:pending_notifications) {
      Notification.where.not(id: ReadNotification.where(user_id: current_user.id).pluck(:notifications_id))
    }

    expose(:tutor_notifications) {
      pending_notifications.where(user: my_tutors.pluck(:tutor_id))
                           .where(client_id: nil)
    }

    expose(:my_notifications) {
      pending_notifications.where(client: current_user)
    }

    expose(:admin_notifications) {
      pending_notifications.where.not(user: my_tutors.pluck(:tutor_id))
                           .where(client_id: nil)
                           .where.not(user: tutor_ids)
                           .where('created_at > ?', current_user.created_at)
    }

    expose(:total_user_notifications) {
      serialized_admin = serialize_notifications(
                            admin_notifications,
                            Api::GenericNotificationSerializer
                          ).as_json
      serialized_tutor_requests = serialize_notifications(
                            tutor_requests,
                            Api::UserTutorSerializer
                          ).as_json

      serialized_my_notifications = serialize_notifications(
                        my_notifications,
                        Api::GenericNotificationSerializer
                      ).as_json

      serialized_tutor_notifications = serialize_notifications(
                        tutor_notifications,
                        Api::GenericNotificationSerializer
                      ).as_json

      serialized_my_notifications +
      serialized_tutor_requests +
      serialized_admin +
{'fraction_non_alphanumeric': 0.07503075030750307, 'fraction_numerical': 0.0009840098400984009, 'mean_word_length': 1.957090909090909, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '3623458', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1081, 'n_words': 137}