mumuki-domain 9.2.1 → 9.3.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: 1f51de9222a3fb2a4f3a4e1f8498d90baf49b4b47b87662193510a601e5c7905
4
- data.tar.gz: b12cf9c00c8b1a2e77e5f758205c89874de9c94e2e5ee8ac3f30f39f6210f272
3
+ metadata.gz: b78b493d9f7e6314a746e22d17fe33c140dada6e77a9af84da850098180a1677
4
+ data.tar.gz: 9ed9017804d844c8a24540dcdf5c32d4ad78d8a28b186e3df1dbd83b845ff5cd
5
5
  SHA512:
6
- metadata.gz: d7ec4c49f78dde3d0422309cf38db8049909eba137b0d4c0ea6b0a27a5d7b475139a351e9c2e272771f9e2b8b59c42c00395511050e3c424369b118b3b23e3d6
7
- data.tar.gz: 3bc5e9b62d860e7ec0092352be7ae556ae93c19a2e4173667e3ed8ff3576de8a2bd6bf07128808c64a3ad791c06d8bb358ddfe8d248766b08a3eb1ab54ad51b0
6
+ metadata.gz: 84faddd371cc851bbb08155cddb140dd6a17eaa3920f73cf235950d3321f07be4dd4f44325708b582904ee4d1eac2b5c426be3afb7b82e566834d87686eec3b2
7
+ data.tar.gz: 93cf6080fba52bffbe3d7fafd4a3ed0121f55accaa8b1c7950e9512a4f409b9031288b51998ab7caff22ac161fd4c0d4c9fb663f369cafb00a42afcfe6ad5732
data/app/models/user.rb CHANGED
@@ -16,6 +16,8 @@ class User < ApplicationRecord
16
16
 
17
17
  has_many :notifications
18
18
  has_many :assignments, foreign_key: :submitter_id
19
+ has_many :indicators
20
+ has_many :user_stats, class_name: 'UserStats'
19
21
  has_many :messages, -> { order(created_at: :desc) }, through: :assignments
20
22
 
21
23
  has_many :submitted_exercises, through: :assignments, class_name: 'Exercise', source: :exercise
@@ -312,6 +314,18 @@ class User < ApplicationRecord
312
314
  UserMailer.certificate(certificate).deliver_later
313
315
  end
314
316
 
317
+ def clear_progress_for!(organization)
318
+ location = { organization: organization }.compact
319
+
320
+ target_assignments = assignments.where(location)
321
+
322
+ messages.where(assignment: target_assignments).delete_all
323
+
324
+ target_assignments.delete_all
325
+ indicators.where(location).delete_all
326
+ user_stats.where(location).delete_all
327
+ end
328
+
315
329
  private
316
330
 
317
331
  def welcome_to_new_organizations!
@@ -31,9 +31,9 @@ class UserStats < ApplicationRecord
31
31
  private
32
32
 
33
33
  def messages_in_discussions_count(date_range = nil)
34
- date_filter = { date: date_range }.compact
34
+ date_filter = { created_at: date_range }.compact
35
35
  result = Message.joins(:discussion)
36
- .where({sender: user.uid, discussions: { organization: organization }}.merge(date_filter))
36
+ .where({sender: user.uid, deletion_motive: nil, discussions: { organization: organization }}.merge(date_filter))
37
37
  .group(:approved)
38
38
  .count
39
39
  unapproved = result[false] || 0
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '9.2.1'
3
+ VERSION = '9.3.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.2.1
4
+ version: 9.3.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-05-11 00:00:00.000000000 Z
11
+ date: 2021-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails