mumuki-domain 9.20.0 → 9.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/gamified.rb +1 -1
- data/app/models/concerns/with_scoped_queries/limit.rb +14 -0
- data/app/models/concerns/with_scoped_queries/page.rb +7 -3
- data/app/models/concerns/with_scoped_queries.rb +1 -1
- data/app/models/discussion.rb +3 -1
- data/app/models/message.rb +7 -2
- data/db/migrate/20211020224011_add_from_moderator_to_messages.rb +5 -0
- data/lib/mumuki/domain/factories/message_factory.rb +1 -1
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95912abc73b50f774b4e87873ea35afa3ce9016d4cf90ce9af6cfb9c88ea9c56
|
4
|
+
data.tar.gz: 3d2cbbf7c128f280edb477d38ad3a37770943ba9a0e6809d54936c62efb54186
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54c74640cdef38c3aeec166b5fded89c82f4f867b37f83a2d0b3e24ef0bb4e0f0b707de265aaae9b56decfe6bdfadc6aa0448fb16506af72119ab3dca0e860c8
|
7
|
+
data.tar.gz: 75949f754f836b0315f5e717532e02de38a8222819d2ae4441df4b524e7fda2c55f45a12696d034060f3a1754120c6707f1cc6d3b9682d591d6c9edd8521fa58
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module WithScopedQueries::Limit
|
2
|
+
def self.query_by(params, current_scope, _)
|
3
|
+
if params[:limit].present?
|
4
|
+
max_limit = [params[:limit].to_i, 25].min
|
5
|
+
current_scope.limit(max_limit)
|
6
|
+
else
|
7
|
+
current_scope
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.add_queriable_attributes_to(klass, _)
|
12
|
+
klass.queriable_attributes.merge!(limit: :limit)
|
13
|
+
end
|
14
|
+
end
|
@@ -1,10 +1,14 @@
|
|
1
1
|
module WithScopedQueries::Page
|
2
2
|
def self.query_by(params, current_scope, _)
|
3
|
-
|
4
|
-
|
3
|
+
if params[:limit].present?
|
4
|
+
current_scope
|
5
|
+
else
|
6
|
+
page_param = params[:page] || 1
|
7
|
+
current_scope.page(page_param).per(10)
|
8
|
+
end
|
5
9
|
end
|
6
10
|
|
7
11
|
def self.add_queriable_attributes_to(klass, _)
|
8
|
-
klass.queriable_attributes.merge!(page: :page)
|
12
|
+
klass.queriable_attributes.merge!(page: [:page, :limit])
|
9
13
|
end
|
10
14
|
end
|
data/app/models/discussion.rb
CHANGED
@@ -22,14 +22,16 @@ class Discussion < ApplicationRecord
|
|
22
22
|
.or(where(responsible_moderator_at: nil)) }
|
23
23
|
scope :pending_review, -> { where(status: :pending_review) }
|
24
24
|
scope :unread_first, -> { includes(:subscriptions).reorder('subscriptions.read', created_at: :desc) }
|
25
|
+
scope :by_recent, -> (_) { where('created_at > ?', Time.now - 6.months)}
|
25
26
|
|
26
27
|
after_create :subscribe_initiator!
|
27
28
|
|
28
29
|
markdown_on :description
|
29
30
|
|
30
31
|
sortable :responses_count, :upvotes_count, :created_at, default: :created_at_desc
|
31
|
-
filterable :status, :language, :requires_attention
|
32
|
+
filterable :status, :language, :requires_attention, :recent
|
32
33
|
pageable
|
34
|
+
limitable
|
33
35
|
|
34
36
|
delegate :language, to: :item
|
35
37
|
delegate :to_discussion_status, to: :status
|
data/app/models/message.rb
CHANGED
@@ -10,6 +10,7 @@ class Message < ApplicationRecord
|
|
10
10
|
validates_presence_of :content, :sender
|
11
11
|
validate :ensure_contextualized
|
12
12
|
|
13
|
+
before_create :mark_from_moderator!
|
13
14
|
after_save :update_counters_cache!
|
14
15
|
|
15
16
|
markdown_on :content
|
@@ -53,7 +54,7 @@ class Message < ApplicationRecord
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def from_moderator?
|
56
|
-
sender_user.moderator_here?
|
57
|
+
from_moderator || sender_user.moderator_here?
|
57
58
|
end
|
58
59
|
|
59
60
|
def from_user?(user)
|
@@ -74,7 +75,7 @@ class Message < ApplicationRecord
|
|
74
75
|
|
75
76
|
def to_resource_h
|
76
77
|
as_json(except: [:id, :type, :discussion_id, :approved, :approved_at, :approved_by_id,
|
77
|
-
:not_actually_a_question, :deletion_motive, :deleted_at, :deleted_by_id],
|
78
|
+
:not_actually_a_question, :deletion_motive, :deleted_at, :deleted_by_id, :from_moderator],
|
78
79
|
include: {exercise: {only: [:bibliotheca_id]}})
|
79
80
|
.merge(organization: Organization.current.name)
|
80
81
|
end
|
@@ -103,6 +104,10 @@ class Message < ApplicationRecord
|
|
103
104
|
approved? || from_moderator?
|
104
105
|
end
|
105
106
|
|
107
|
+
def mark_from_moderator!
|
108
|
+
self.from_moderator = from_moderator?
|
109
|
+
end
|
110
|
+
|
106
111
|
def update_counters_cache!
|
107
112
|
discussion&.update_counters!
|
108
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-domain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Leonardo Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -306,6 +306,7 @@ files:
|
|
306
306
|
- app/models/concerns/with_responsible_moderator.rb
|
307
307
|
- app/models/concerns/with_scoped_queries.rb
|
308
308
|
- app/models/concerns/with_scoped_queries/filter.rb
|
309
|
+
- app/models/concerns/with_scoped_queries/limit.rb
|
309
310
|
- app/models/concerns/with_scoped_queries/page.rb
|
310
311
|
- app/models/concerns/with_scoped_queries/sort.rb
|
311
312
|
- app/models/concerns/with_slug.rb
|
@@ -687,6 +688,7 @@ files:
|
|
687
688
|
- db/migrate/20210719145706_add_new_fields_to_notifications.rb
|
688
689
|
- db/migrate/20210803175124_add_ignored_notifications_to_users.rb
|
689
690
|
- db/migrate/20210929223144_add_authorization_requests_limit_to_exam_registration.rb
|
691
|
+
- db/migrate/20211020224011_add_from_moderator_to_messages.rb
|
690
692
|
- lib/mumuki/domain.rb
|
691
693
|
- lib/mumuki/domain/area.rb
|
692
694
|
- lib/mumuki/domain/engine.rb
|