openstax_accounts 9.5.0 → 9.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48ae6fdbc68368694770f436f5a7a4e57dea39b18c93b2791308aace6b07a02a
4
- data.tar.gz: bbfbe2609b86b3b216ad0a94c7bf41b7c6bc1b29ea65e4a99388288dfcc80f7f
3
+ metadata.gz: 3bbc4f9d4b0e45a223ac13d149012a2f27fc8ab8b77d71aa2213f447974ae0ee
4
+ data.tar.gz: fed8b3ecbf12bbd0cf45ca9f11a0e73a98c4a4157f97733ce3b2672ecb8bc7ff
5
5
  SHA512:
6
- metadata.gz: 29b93ef99bbb0ee170f4619269e79dd94fd89634a328985d55a057b9f0c85980480fdf8bfe47d4e946fb9dfc42e3a91c7e087a1825b8067c7c4a68d27e56f70f
7
- data.tar.gz: dd689a226b1f8c92be65d8543c917b35af81eafa9a90f9de3b718fc2cf7b14e4df0ed7f64aff883bc2cf2141bfe1122dffadb9841a7cf0b1df9147e7b419779c
6
+ metadata.gz: eaf4336be588df387e67d9f79633f398053f655c10d624f29d2d0dfe027854a5def31a12c70e088edd7069633762c12707e481cf078e12ea9a389d98b43658be
7
+ data.tar.gz: 98a1fd1915f40aaf349112a28d91a359cc5ec2b8fbeb230d7192e423b07aaab0a65a367367c400bf2ac3ed3180158561a3abcd9a4e930ea6e2c0af18e0dc88d3
@@ -1,7 +1,5 @@
1
1
  # Routine for getting account updates from the Accounts server
2
- #
3
2
  # Should be scheduled to run regularly
4
-
5
3
  module OpenStax
6
4
  module Accounts
7
5
  class SyncAccounts
@@ -12,36 +10,40 @@ module OpenStax
12
10
  def exec(options={})
13
11
  return if OpenStax::Accounts.configuration.enable_stubbing?
14
12
 
15
- response = OpenStax::Accounts::Api.get_application_account_updates
13
+ loop do
14
+ response = OpenStax::Accounts::Api.get_application_account_updates
16
15
 
17
- app_accounts = []
18
- app_accounts_rep = OpenStax::Accounts::Api::V1::ApplicationAccountsRepresenter
19
- .new(app_accounts)
20
- app_accounts_rep.from_json(response.body)
16
+ app_accounts = []
17
+ app_accounts_rep = OpenStax::Accounts::Api::V1::ApplicationAccountsRepresenter.new(
18
+ app_accounts
19
+ )
20
+ app_accounts_rep.from_json(response.body)
21
21
 
22
- return if app_accounts.empty?
22
+ num_accounts = app_accounts.size
23
+ return if num_accounts == 0
23
24
 
24
- updated_app_accounts = []
25
- app_accounts.each do |app_account|
26
- account = OpenStax::Accounts::Account.find_by(
27
- uuid: app_account.account.uuid
28
- ) || app_account.account
29
- account.syncing = true
25
+ updated_app_accounts = []
26
+ app_accounts.each do |app_account|
27
+ account = OpenStax::Accounts::Account.find_by(
28
+ uuid: app_account.account.uuid
29
+ ) || app_account.account
30
+ account.syncing = true
30
31
 
31
- if account != app_account.account
32
32
  OpenStax::Accounts::Account::SYNC_ATTRIBUTES.each do |attribute|
33
- account.send("#{attribute}=", app_account.account.send(attribute))
34
- end
33
+ account.send "#{attribute}=", app_account.account.send(attribute)
34
+ end if account != app_account.account
35
+
36
+ next unless account.save
37
+
38
+ updated_app_accounts << {
39
+ user_id: account.openstax_uid, read_updates: app_account.unread_updates
40
+ }
35
41
  end
36
42
 
37
- next unless account.save
43
+ OpenStax::Accounts::Api.mark_account_updates_as_read(updated_app_accounts)
38
44
 
39
- updated_app_accounts << {
40
- user_id: account.openstax_uid, read_updates: app_account.unread_updates
41
- }
45
+ return if num_accounts < OpenStax::Accounts.configuration.max_user_updates_per_request
42
46
  end
43
-
44
- OpenStax::Accounts::Api.mark_account_updates_as_read(updated_app_accounts)
45
47
  end
46
48
  end
47
49
  end
@@ -81,7 +81,9 @@ module OpenStax
81
81
  # On success, returns an OAuth2::Response object.
82
82
  def self.get_application_account_updates(options = {})
83
83
  limit = OpenStax::Accounts.configuration.max_user_updates_per_request
84
- request(:get, "application_users/updates#{ '?limit=' + limit.to_s if !limit.blank? }", options)
84
+ request(
85
+ :get, "application_users/updates#{ '?limit=' + limit.to_s if !limit.blank? }", options
86
+ )
85
87
  end
86
88
 
87
89
  # Marks account updates as "read".
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Accounts
3
- VERSION = '9.5.0'
3
+ VERSION = '9.5.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_accounts
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.5.0
4
+ version: 9.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-03 00:00:00.000000000 Z
11
+ date: 2020-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails