mumuki-domain 9.7.0 → 9.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f0a85995ceefa3f9400d60e29b11c3907b1c42853c2d1517138bc7fa4532239
4
- data.tar.gz: d468a495d0c21ee1139b4087c7ce5653936d7b9289a5a06d2e7c338f443fe128
3
+ metadata.gz: 801f11c820f31c39323edff06d235e0c48804b1454f5dbd118363a34f153808f
4
+ data.tar.gz: daaa6a61637d5d52412fee38276de7c2ebad10cb696f28b912cbe4ef3ca49247
5
5
  SHA512:
6
- metadata.gz: f5ddf066cff9cf215e1ad83041b418cf615dcf3f5674b97cc569725d53f2107f2fc4c33b5d75fc3ae36e9a16694eeac90318062a65b3b1f1c003f97924359119
7
- data.tar.gz: 0200b8bf90e1e7c08797fd2f3c417b744be4c455ff40cff1063fd7f8bf9a28f143f7d272a85e765ef02b663f10957b1ee5fa647b32331ea953bb6b7d8cbf4e0c
6
+ metadata.gz: 4b0370b955ddf9ae29c02dde36613b1bde7fcd3c3711e55f20744bcdcd283e711f461ad6ab2766b0b560fa7e845a401a2cf0172d4a04d7223eb93671ea85e95f
7
+ data.tar.gz: 1ea134ed3fe1ac847c524eff4479463f7a75c6d96ef2ecdcb6ef2c62162c38ab0effaae3e76da02c57666418747fd01753c3b369f5a0dae1058b794dac22c067
@@ -15,14 +15,19 @@ class Discussion < ApplicationRecord
15
15
 
16
16
  scope :by_language, -> (language) { includes(:exercise).joins(exercise: :language).where(languages: {name: language}) }
17
17
  scope :order_by_responses_count, -> (direction) { reorder(validated_messages_count: direction, messages_count: opposite(direction)) }
18
- scope :by_requires_moderator_response, -> (boolean) { where(requires_moderator_response: boolean.to_boolean) }
18
+ scope :by_requires_attention, -> (boolean) { opened_and_requires_moderator_response(boolean).or(pending_review).no_responsible_moderator }
19
+ scope :opened_and_requires_moderator_response, -> (boolean) { where(requires_moderator_response: boolean.to_boolean)
20
+ .where(status: :opened) }
21
+ scope :no_responsible_moderator, -> { where('responsible_moderator_at < ?', Time.now - MODERATOR_MAX_RESPONSIBLE_TIME)
22
+ .or(where(responsible_moderator_at: nil)) }
23
+ scope :pending_review, -> { where(status: :pending_review) }
19
24
 
20
25
  after_create :subscribe_initiator!
21
26
 
22
27
  markdown_on :description
23
28
 
24
29
  sortable :responses_count, :upvotes_count, :created_at, default: :created_at_desc
25
- filterable :status, :language, :requires_moderator_response
30
+ filterable :status, :language, :requires_attention
26
31
  pageable
27
32
 
28
33
  delegate :language, to: :item
@@ -145,6 +150,14 @@ class Discussion < ApplicationRecord
145
150
  validated_messages_count > 0
146
151
  end
147
152
 
153
+ def requires_attention_for?(user)
154
+ user&.moderator_here? && requires_attention?
155
+ end
156
+
157
+ def requires_attention?
158
+ no_current_responsible? && status.requires_attention_for?(self)
159
+ end
160
+
148
161
  def subscribe_initiator!
149
162
  initiator.subscribe_to! self
150
163
  end
@@ -11,7 +11,7 @@ class UserStats < ApplicationRecord
11
11
  end
12
12
 
13
13
  def activity(date_range = nil)
14
- date_filter = { submitted_at: date_range }.compact
14
+ date_filter = { updated_at: date_range }.compact
15
15
  {
16
16
  exercises: {
17
17
  solved_count: organization_exercises
@@ -12,4 +12,8 @@ module Mumuki::Domain::Status::Discussion::Closed
12
12
  def self.iconize
13
13
  {class: :danger, type: 'times-circle'}
14
14
  end
15
+
16
+ def self.requires_attention_for?(_)
17
+ false
18
+ end
15
19
  end
@@ -28,4 +28,8 @@ module Mumuki::Domain::Status::Discussion::Opened
28
28
  def self.should_be_shown?(*)
29
29
  true
30
30
  end
31
+
32
+ def self.requires_attention_for?(discussion)
33
+ discussion.requires_moderator_response?
34
+ end
31
35
  end
@@ -12,4 +12,8 @@ module Mumuki::Domain::Status::Discussion::PendingReview
12
12
  def self.iconize
13
13
  {class: :info, type: 'hourglass'}
14
14
  end
15
+
16
+ def self.requires_attention_for?(_)
17
+ true
18
+ end
15
19
  end
@@ -16,4 +16,8 @@ module Mumuki::Domain::Status::Discussion::Solved
16
16
  def self.should_be_shown?(*)
17
17
  true
18
18
  end
19
+
20
+ def self.requires_attention_for?(_)
21
+ false
22
+ end
19
23
  end
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '9.7.0'
3
+ VERSION = '9.8.0'
4
4
  end
5
5
  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.7.0
4
+ version: 9.8.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-06-17 00:00:00.000000000 Z
11
+ date: 2021-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails