mumuki-domain 8.6.0 → 8.6.1

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: 0fc67d5d416345806e5d570dae375114d9bd32e3be5af26485a926c9957d10f2
4
- data.tar.gz: cb223b383c8f176ac852091b8cf79ed2f496404bc75d1d7dcc3ccfbde70e49f2
3
+ metadata.gz: 339d512e2040015c6556f9671fd00281edf9b651a5dc9db8f860d7607989cd65
4
+ data.tar.gz: a03fe1fe26593986af16d89c1df6cc6e9b8f21c3e9e240de41f884482e75c6d7
5
5
  SHA512:
6
- metadata.gz: 3a891889e37c9fd9a55c383f2ffe6aa2f9368193bb7550ba34d9253fb8fbab3534be85ac6acc8a162f02907059acc57da14658ee6df7ad19ad93523ee1ef998d
7
- data.tar.gz: e830934dd132b0bada6f45348249f06d170438c98fbb07528fa1e608397b40945485adeb4a79e732d701371e4196a9fae22c5e4ba68ef983a71dc7ae40236704
6
+ metadata.gz: ea2475a456f0558a61e798d27e88921a7a69b134dc38431c1244033d778dbc1b91ce4a974acaa6abbf77cceed03134430cb378f2e4d4561f39d297a7040a9745
7
+ data.tar.gz: 1321dbd879300fb21e87ef044bae0a7bcbca62ff9fc27cf55bfac1e02cc122273952add367a94381a54e1b730e68549659e5abb9762795071e8c7fa89d6a3699
data/app/models/book.rb CHANGED
@@ -18,7 +18,7 @@ class Book < Content
18
18
  end
19
19
 
20
20
  def discussions_in_organization(organization = Organization.current)
21
- Discussion.where(organization: organization).includes(exercise: [:language, :guide])
21
+ Discussion.where(organization: organization, item: organization.exercises).includes(exercise: [:language, :guide])
22
22
  end
23
23
 
24
24
  def first_chapter
@@ -138,6 +138,10 @@ class Organization < ApplicationRecord
138
138
  self[:progressive_display_lookahead] = lookahead.to_i.positive? ? lookahead : nil
139
139
  end
140
140
 
141
+ def activity_start_date(default_date)
142
+ [default_date, in_preparation_until&.to_date].compact.max
143
+ end
144
+
141
145
  # ==============
142
146
  # Display fields
143
147
  # ==============
@@ -10,7 +10,39 @@ class UserStats < ApplicationRecord
10
10
  self.stats_for(user).exp
11
11
  end
12
12
 
13
+ def activity(date_range = nil)
14
+ date_filter = { submitted_at: date_range }.compact
15
+ {
16
+ exercises: {
17
+ solved_count: organization_exercises
18
+ .joins(:assignments)
19
+ .where(assignments: { top_submission_status: [:passed, :skipped], submitter: user }.merge(date_filter))
20
+ .count,
21
+ count: organization_exercises.count},
22
+
23
+ messages: messages_in_discussions_count(date_range)
24
+ }
25
+ end
26
+
13
27
  def add_exp!(points)
14
28
  self.exp += points
15
29
  end
30
+
31
+ private
32
+
33
+ def messages_in_discussions_count(date_range = nil)
34
+ date_filter = { date: date_range }.compact
35
+ result = Message.joins(:discussion)
36
+ .where({sender: user.uid, discussions: { organization: organization }}.merge(date_filter))
37
+ .group(:approved)
38
+ .count
39
+ unapproved = result[false] || 0
40
+ approved = result[true] || 0
41
+
42
+ { count: unapproved + approved, approved: approved }
43
+ end
44
+
45
+ def organization_exercises
46
+ @organization_exercises ||= organization.exercises
47
+ end
16
48
  end
@@ -4,4 +4,17 @@ FactoryBot.define do
4
4
  description { Faker::Lorem.sentence(word_count: 30) }
5
5
  slug { "mumuki/mumuki-test-book-#{SecureRandom.uuid}" }
6
6
  end
7
+
8
+ factory :book_with_full_tree, parent: :book do
9
+ transient do
10
+ children_factor { 3 }
11
+ exercises { create_list(:exercise, children_factor) }
12
+ lessons { create_list(:lesson, children_factor, exercises: exercises) }
13
+ chapters { create_list(:chapter, children_factor, lessons: lessons) }
14
+ end
15
+
16
+ after(:build) do |book, evaluator|
17
+ book.chapters = evaluator.chapters
18
+ end
19
+ end
7
20
  end
@@ -90,6 +90,9 @@ module Mumuki::Domain
90
90
  def visit!(*)
91
91
  end
92
92
 
93
+ def currently_in_exam?
94
+ false
95
+ end
93
96
  # ========
94
97
  # Progress
95
98
  # ========
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '8.6.0'
3
+ VERSION = '8.6.1'
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: 8.6.0
4
+ version: 8.6.1
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-02-11 00:00:00.000000000 Z
11
+ date: 2021-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails