diff --git a/app/graphql/types/client_type.rb b/app/graphql/types/client_type.rb index 7d99e39dc..744b7ac66 100644 --- a/app/graphql/types/client_type.rb +++ b/app/graphql/types/client_type.rb @@ -25,9 +25,9 @@ class ClientType < GraphQL::Schema::Object end def prefixes(**args) - collection = object.prefixes + collection = object.client_prefixes.joins(:prefix) collection = collection.query(args[:query]) if args[:query].present? - collection = collection.where('YEAR(prefix.created) = ?', args[:year]) if args[:year].present? + collection = collection.where('YEAR(datacentre_prefixes.created_at) = ?', args[:year]) if args[:year].present? collection end diff --git a/app/graphql/types/prefix_connection_with_total_count_type.rb b/app/graphql/types/prefix_connection_with_total_count_type.rb index d242574b2..170aaa734 100644 --- a/app/graphql/types/prefix_connection_with_total_count_type.rb +++ b/app/graphql/types/prefix_connection_with_total_count_type.rb @@ -16,6 +16,7 @@ def states if object.parent.class.name == "Provider" collection = object.parent.provider_prefixes.joins(:prefix) + collection = collection.where('YEAR(allocator_prefixes.created_at) = ?', args[:year]) if args[:year].present? if args[:state].present? [{ id: args[:state], @@ -39,6 +40,7 @@ def years if object.parent.class.name == "Provider" collection = object.parent.provider_prefixes.joins(:prefix) + collection = collection.state(args[:state].underscore.dasherize) if args[:state].present? if args[:year].present? [{ id: args[:year], diff --git a/app/graphql/types/provider_type.rb b/app/graphql/types/provider_type.rb index 37c0aa34a..9e98ad707 100644 --- a/app/graphql/types/provider_type.rb +++ b/app/graphql/types/provider_type.rb @@ -29,10 +29,10 @@ class ProviderType < BaseObject end def prefixes(**args) - collection = object.prefixes + collection = object.provider_prefixes.joins(:prefix) collection = collection.state(args[:state].underscore.dasherize) if args[:state].present? collection = collection.query(args[:query]) if args[:query].present? - collection = collection.where('YEAR(prefix.created) = ?', args[:year]) if args[:year].present? + collection = collection.where('YEAR(allocator_prefixes.created_at) = ?', args[:year]) if args[:year].present? collection end