Browse Source

Maintenance: Clarify user and organization tickets counting

Mantas Masalskis 5 months ago
parent
commit
77c6e3864a

+ 10 - 7
app/graphql/gql/types/ticket_count_type.rb

@@ -1,5 +1,8 @@
 # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
 
+# This type counts user or organization tickets accessible to *current user*
+# It is very similar to what TicketUserTicketCounterJob does but not the same!
+# This counter is used exclusively in New Tech stack
 module Gql::Types
   class TicketCountType < Gql::Types::BaseObject
     description 'Open and closed ticket information'
@@ -28,14 +31,14 @@ module Gql::Types
     end
 
     def object_key_column
-      case @object.class.name
-      when 'Organization'
-        return 'organization_id'
-      when 'User'
-        return 'customer_id'
+      case @object
+      when ::Organization
+        'organization_id'
+      when ::User
+        'customer_id'
+      else
+        raise "Unknown object type #{@object.class}"
       end
-
-      raise "Unknown object type #{@object.class.name}"
     end
   end
 end

+ 3 - 0
app/jobs/ticket_user_ticket_counter_job.rb

@@ -1,5 +1,8 @@
 # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
 
+# This job counts *all* user tickets and stores the count in the user preferences
+# It is very similar to what Gql::Types::TicketCountType does but not the same!
+# Results of this job are used exclusively in the old UI
 class TicketUserTicketCounterJob < ApplicationJob
   include HasActiveJobLock