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