active_recall 1.6.3 → 1.6.4

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: 2e993b98e9627ec06e8eae73c3fba15a6ed761b66dbb1092b1355140cb2bd366
4
- data.tar.gz: 5402a3ae205e52b20587ab73a5d819eaf7102dea5d52cf983e4be5beddf5279d
3
+ metadata.gz: 90faada77c84371101ce19140d8c0e113fa06a831ed0c11613ac46bc7221a798
4
+ data.tar.gz: 6aaaf972df81c2341143307c4998bcb7c0b0017e1e0979bc54b8bddaf5a74d86
5
5
  SHA512:
6
- metadata.gz: aba48fb3870fd48fba35a371b48ceeaad4fb306acef718175f67451ee25111ec6389faaf0c52d9424ad1b87da94faf1c24b66f32f920392fa4b7e68ebbb27699
7
- data.tar.gz: 2c9c4651bd1e4ac541ffb4c258e899bf311cd84ec6cc4490b643ef1a27bc236c9820e5e30b5af22ee4673413dfad5e0bacbdbcd7344494c9df2059e3472fee17
6
+ metadata.gz: 3a4cf31bf1d9860b954aaaf482dfc4ac990012b6ea65432135f267d324505ddad9f856deca45318c3671b69b339c1a53bc8b6c10bb99ce3bad54db6f5b4736ea
7
+ data.tar.gz: 87cb8640cf8f2ed2bdcdda45c36064f943c303d001155676160f357b1190d64b6451ac3d68091d92f7db6cc7c64b6cb4c73a10781c390ea0edfb89185e69ad4f
data/Gemfile.lock CHANGED
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_recall (1.6.3)
4
+ active_recall (1.6.4)
5
5
  activerecord (>= 5.2.3, <= 6.2)
6
6
  activesupport (>= 5.2.3, <= 6.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (6.1.4)
12
- activesupport (= 6.1.4)
13
- activerecord (6.1.4)
14
- activemodel (= 6.1.4)
15
- activesupport (= 6.1.4)
16
- activesupport (6.1.4)
11
+ activemodel (6.1.4.1)
12
+ activesupport (= 6.1.4.1)
13
+ activerecord (6.1.4.1)
14
+ activemodel (= 6.1.4.1)
15
+ activesupport (= 6.1.4.1)
16
+ activesupport (6.1.4.1)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 1.6, < 2)
19
19
  minitest (>= 5.1)
@@ -42,21 +42,12 @@ module ActiveRecall
42
42
  .destroy
43
43
  end
44
44
 
45
- # OPTIMIZE: Attempt in active record, rather than array of Ruby records
46
45
  def review
47
- %i[untested failed expired].inject([]) do |words, s|
48
- words += items.send(s).order(random_order_function).map(&:source)
49
- end
46
+ _review.map(&:source)
50
47
  end
51
48
 
52
- # OPTIMIZE: Use optimized #review and build only the record to be returned
53
49
  def next
54
- word = nil
55
- %i[untested failed expired].each do |category|
56
- word = items.send(category).order(random_order_function).limit(1).map(&:source).first
57
- break if word
58
- end
59
- word
50
+ _review.first.try(:source)
60
51
  end
61
52
 
62
53
  def last
@@ -89,6 +80,14 @@ module ActiveRecall
89
80
 
90
81
  private
91
82
 
83
+ def _review
84
+ items
85
+ .untested
86
+ .or(items.failed)
87
+ .or(items.expired)
88
+ .order(random_order_function)
89
+ end
90
+
92
91
  def random_order_function
93
92
  Arel.sql(mysql? ? 'RAND()' : 'random()')
94
93
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecall
4
- VERSION = '1.6.3'
4
+ VERSION = '1.6.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_recall
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gravina
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-08-12 00:00:00.000000000 Z
12
+ date: 2021-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake