decidim-comments 0.30.3 → 0.31.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/cells/decidim/comments/comment/deletion_data.erb +1 -1
- data/app/cells/decidim/comments/comment/show.erb +12 -12
- data/app/cells/decidim/comments/comment_cell.rb +1 -3
- data/app/cells/decidim/comments/comment_form/comment_as.erb +5 -24
- data/app/cells/decidim/comments/comment_form/show.erb +3 -3
- data/app/cells/decidim/comments/comment_form_cell.rb +5 -20
- data/app/cells/decidim/comments/comments/order_control.erb +7 -5
- data/app/cells/decidim/comments/comments_cell.rb +1 -1
- data/app/cells/decidim/comments/edit_comment_modal_form/show.erb +2 -2
- data/app/commands/decidim/comments/create_comment.rb +3 -5
- data/app/events/decidim/comments/comment_event.rb +3 -10
- data/app/forms/decidim/comments/comment_form.rb +0 -1
- data/app/models/decidim/comments/comment.rb +2 -2
- data/app/models/decidim/comments/seed.rb +4 -16
- data/app/packs/src/decidim/comments/comments.component.js +0 -20
- data/app/packs/src/decidim/comments/comments.component.test.js +4 -16
- data/app/packs/src/decidim/comments/comments.js +1 -1
- data/app/packs/src/decidim/comments/comments_mobile_modal.js +1 -1
- data/app/packs/stylesheets/comments.scss +2 -6
- data/app/queries/decidim/comments/sorted_comments.rb +1 -1
- data/app/services/decidim/comments/new_comment_notification_creator.rb +2 -27
- data/app/views/decidim/comments/admin/shared/_availability_fields.html.erb +1 -1
- data/app/views/decidim/comments/comments/delete.js.erb +4 -2
- data/app/views/decidim/comments/comments/reload.js.erb +0 -2
- data/app/views/decidim/comments/comments/update.js.erb +3 -1
- data/config/assets.rb +2 -2
- data/config/locales/ar.yml +0 -18
- data/config/locales/bg.yml +0 -18
- data/config/locales/bs-BA.yml +0 -8
- data/config/locales/ca-IT.yml +0 -20
- data/config/locales/ca.yml +0 -20
- data/config/locales/cs.yml +0 -20
- data/config/locales/de.yml +1 -21
- data/config/locales/el.yml +0 -18
- data/config/locales/en.yml +0 -20
- data/config/locales/es-MX.yml +0 -20
- data/config/locales/es-PY.yml +0 -20
- data/config/locales/es.yml +0 -20
- data/config/locales/eu.yml +1 -21
- data/config/locales/fi-plain.yml +0 -20
- data/config/locales/fi.yml +0 -20
- data/config/locales/fr-CA.yml +0 -23
- data/config/locales/fr.yml +0 -23
- data/config/locales/ga-IE.yml +0 -5
- data/config/locales/gl.yml +0 -11
- data/config/locales/hu.yml +0 -18
- data/config/locales/id-ID.yml +0 -11
- data/config/locales/is-IS.yml +0 -5
- data/config/locales/it.yml +0 -18
- data/config/locales/ja.yml +0 -20
- data/config/locales/lb.yml +0 -18
- data/config/locales/lt.yml +0 -18
- data/config/locales/lv.yml +0 -18
- data/config/locales/nl.yml +0 -18
- data/config/locales/no.yml +0 -18
- data/config/locales/pl.yml +0 -18
- data/config/locales/pt-BR.yml +0 -18
- data/config/locales/pt.yml +0 -18
- data/config/locales/ro-RO.yml +0 -20
- data/config/locales/ru.yml +0 -11
- data/config/locales/si-LK.yml +0 -2
- data/config/locales/sk.yml +0 -18
- data/config/locales/sq-AL.yml +0 -2
- data/config/locales/sr-CS.yml +0 -9
- data/config/locales/sv.yml +0 -20
- data/config/locales/tr-TR.yml +0 -18
- data/config/locales/uk.yml +0 -6
- data/config/locales/zh-CN.yml +0 -18
- data/config/locales/zh-TW.yml +0 -18
- data/db/migrate/20181003080320_fix_user_groups_ids_in_comments.rb +8 -1
- data/lib/decidim/api/comment_type.rb +1 -4
- data/lib/decidim/api/commentable_interface.rb +7 -13
- data/lib/decidim/api/commentable_mutation_type.rb +2 -3
- data/lib/decidim/comments/comment_serializer.rb +0 -4
- data/lib/decidim/comments/comment_vote_serializer.rb +0 -4
- data/lib/decidim/comments/commentable.rb +4 -0
- data/lib/decidim/comments/engine.rb +6 -20
- data/lib/decidim/comments/test/factories.rb +1 -1
- data/lib/decidim/comments/test/shared_examples/comment_event.rb +1 -10
- data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +0 -2
- data/lib/decidim/comments/version.rb +1 -1
- metadata +8 -12
- data/app/events/decidim/comments/comment_by_followed_user_group_event.rb +0 -9
- data/app/events/decidim/comments/user_group_mentioned_event.rb +0 -10
- data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +0 -50
- data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +0 -97
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Comments
|
|
5
|
-
module Metrics
|
|
6
|
-
# Searches for Participants in the following actions
|
|
7
|
-
# - Leave a comment (Comments)
|
|
8
|
-
class CommentParticipantsMetricMeasure < Decidim::MetricMeasure
|
|
9
|
-
def valid?
|
|
10
|
-
super && @resource.is_a?(Decidim::Participable)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def calculate
|
|
14
|
-
cumulative_users = []
|
|
15
|
-
quantity_users = []
|
|
16
|
-
|
|
17
|
-
retrieve_comments_for_organization.each do |comment|
|
|
18
|
-
related_object = comment.root_commentable
|
|
19
|
-
next unless related_object
|
|
20
|
-
next unless check_participatory_space(@resource, related_object)
|
|
21
|
-
|
|
22
|
-
cumulative_users << comment.decidim_author_id
|
|
23
|
-
quantity_users << comment.decidim_author_id if comment.created_at >= start_time
|
|
24
|
-
end
|
|
25
|
-
{
|
|
26
|
-
cumulative_users: cumulative_users.uniq,
|
|
27
|
-
quantity_users: quantity_users.uniq
|
|
28
|
-
}
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
def check_participatory_space(participatory_space, related_object)
|
|
34
|
-
return related_object.participatory_space == participatory_space if related_object.respond_to?(:participatory_space)
|
|
35
|
-
return related_object == participatory_space if related_object.is_a?(Decidim::Participable)
|
|
36
|
-
|
|
37
|
-
false
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def retrieve_comments_for_organization
|
|
41
|
-
user_ids = Decidim::User.where(organization: @resource.organization).pluck(:id)
|
|
42
|
-
Decidim::Comments::Comment.includes(:root_commentable).not_hidden.not_deleted
|
|
43
|
-
.where(decidim_comments_comments: { created_at: ..end_time })
|
|
44
|
-
.where(decidim_comments_comments: { decidim_author_id: user_ids })
|
|
45
|
-
.where(decidim_comments_comments: { decidim_author_type: "Decidim::UserBaseEntity" })
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Comments
|
|
5
|
-
module Metrics
|
|
6
|
-
class CommentsMetricManage < Decidim::MetricManage
|
|
7
|
-
def metric_name
|
|
8
|
-
"comments"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def save
|
|
12
|
-
query.each do |key, results|
|
|
13
|
-
cumulative_value = results[:cumulative]
|
|
14
|
-
next if cumulative_value.zero?
|
|
15
|
-
|
|
16
|
-
quantity_value = results[:quantity] || 0
|
|
17
|
-
space_type, space_id, taxonomy_id, related_object_type, related_object_id = key
|
|
18
|
-
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
|
|
19
|
-
participatory_space_type: space_type, participatory_space_id: space_id,
|
|
20
|
-
organization: @organization, decidim_taxonomy_id: taxonomy_id,
|
|
21
|
-
related_object_type:, related_object_id:)
|
|
22
|
-
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
|
23
|
-
record.save!
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
# Creates a Hashed structure with comments grouped by
|
|
30
|
-
#
|
|
31
|
-
# - ParticipatorySpace (type & ID)
|
|
32
|
-
# - Taxonomy (ID)
|
|
33
|
-
# - RelatedObject (type & ID)
|
|
34
|
-
#
|
|
35
|
-
def query
|
|
36
|
-
return @query if @query
|
|
37
|
-
|
|
38
|
-
@query = retrieve_comments.each_with_object({}) do |comment, grouped_comments|
|
|
39
|
-
related_object = comment.root_commentable
|
|
40
|
-
next grouped_comments unless related_object
|
|
41
|
-
|
|
42
|
-
group_keys = generate_group_keys(related_object)
|
|
43
|
-
|
|
44
|
-
next grouped_comments unless group_keys
|
|
45
|
-
|
|
46
|
-
group_keys.map do |group_key|
|
|
47
|
-
grouped_comments[group_key] ||= { cumulative: 0, quantity: 0 }
|
|
48
|
-
grouped_comments[group_key][:cumulative] += 1
|
|
49
|
-
grouped_comments[group_key][:quantity] += 1 if comment.created_at >= start_time
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
@query
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Retrieve Comments generated within an Organization
|
|
57
|
-
#
|
|
58
|
-
# Uses 'author' and 'user_group' relationship
|
|
59
|
-
#
|
|
60
|
-
def retrieve_comments
|
|
61
|
-
user_ids = Decidim::User.select(:id).where(organization: @organization).collect(&:id)
|
|
62
|
-
user_group_ids = Decidim::UserGroup.select(:id).where(organization: @organization).collect(&:id)
|
|
63
|
-
Decidim::Comments::Comment.includes(:root_commentable).not_hidden.not_deleted
|
|
64
|
-
.where(decidim_comments_comments: { created_at: ..end_time })
|
|
65
|
-
.where("decidim_comments_comments.decidim_author_id IN (?) OR
|
|
66
|
-
decidim_comments_comments.decidim_user_group_id IN (?)", user_ids, user_group_ids)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Generates a group key from the related object of a Comment
|
|
70
|
-
def generate_group_keys(related_object)
|
|
71
|
-
participatory_space = retrieve_participatory_space(related_object)
|
|
72
|
-
return unless participatory_space
|
|
73
|
-
|
|
74
|
-
return unless related_object.respond_to?(:taxonomies)
|
|
75
|
-
|
|
76
|
-
taxonomy_ids = related_object.taxonomies.pluck(:id)
|
|
77
|
-
taxonomy_ids.each_with_object([]) do |taxonomy_id, group_keys|
|
|
78
|
-
group_key = []
|
|
79
|
-
group_key += [participatory_space.class.name, participatory_space.id]
|
|
80
|
-
group_key += [taxonomy_id]
|
|
81
|
-
group_key += [related_object.class.name, related_object.id]
|
|
82
|
-
group_keys << group_key
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# Gets current ParticipatorySpace of a given 'related_object'
|
|
87
|
-
def retrieve_participatory_space(related_object)
|
|
88
|
-
if related_object.respond_to?(:participatory_space)
|
|
89
|
-
related_object.participatory_space
|
|
90
|
-
elsif related_object.is_a?(Decidim::Participable)
|
|
91
|
-
related_object
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|