mumuki-domain 8.6.0 → 8.6.1
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/models/book.rb +1 -1
- data/app/models/organization.rb +4 -0
- data/app/models/user_stats.rb +32 -0
- data/lib/mumuki/domain/factories/book_factory.rb +13 -0
- data/lib/mumuki/domain/incognito.rb +3 -0
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 339d512e2040015c6556f9671fd00281edf9b651a5dc9db8f860d7607989cd65
|
|
4
|
+
data.tar.gz: a03fe1fe26593986af16d89c1df6cc6e9b8f21c3e9e240de41f884482e75c6d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/app/models/organization.rb
CHANGED
|
@@ -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
|
# ==============
|
data/app/models/user_stats.rb
CHANGED
|
@@ -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
|
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.
|
|
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
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|