Show taggings in API
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
class Tag < ActsAsTaggableOn::Tag
|
||||
|
||||
def self.public_for_api
|
||||
where("kind IS NULL OR kind = 'category'")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -22,6 +22,7 @@ Debate:
|
||||
comments: [Comment]
|
||||
public_author: User
|
||||
votes: [Vote]
|
||||
tags: ["ActsAsTaggableOn::Tag"]
|
||||
Proposal:
|
||||
fields:
|
||||
id: integer
|
||||
@@ -44,6 +45,7 @@ Proposal:
|
||||
proposal_notifications: [ProposalNotification]
|
||||
public_author: User
|
||||
votes: [Vote]
|
||||
tags: ["ActsAsTaggableOn::Tag"]
|
||||
Comment:
|
||||
fields:
|
||||
id: integer
|
||||
@@ -69,7 +71,7 @@ ProposalNotification:
|
||||
proposal_id: integer
|
||||
created_at: string
|
||||
proposal: Proposal
|
||||
Tag:
|
||||
ActsAsTaggableOn::Tag:
|
||||
fields:
|
||||
id: integer
|
||||
name: string
|
||||
|
||||
@@ -20,6 +20,8 @@ module ActsAsTaggableOn
|
||||
|
||||
Tag.class_eval do
|
||||
|
||||
include Graphqlable
|
||||
|
||||
def increment_custom_counter_for(taggable_type)
|
||||
Tag.increment_counter(custom_counter_field_name_for(taggable_type), id)
|
||||
end
|
||||
@@ -42,10 +44,14 @@ module ActsAsTaggableOn
|
||||
ActsAsTaggableOn::Tag.where('taggings.taggable_type' => 'SpendingProposal').includes(:taggings).order(:name).uniq
|
||||
end
|
||||
|
||||
def self.public_for_api
|
||||
where("kind IS NULL OR kind = 'category'")
|
||||
end
|
||||
|
||||
private
|
||||
def custom_counter_field_name_for(taggable_type)
|
||||
"#{taggable_type.underscore.pluralize}_count"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user