Skip to content

Commit

Permalink
correctly count prefixes. #269
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed May 11, 2019
1 parent c24f0da commit bb24308
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/graphql/types/client_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions app/graphql/types/prefix_connection_with_total_count_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/provider_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bb24308

Please sign in to comment.