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 +4 -4
- data/app/routines/openstax/accounts/sync_accounts.rb +25 -23
- data/lib/openstax/accounts/api.rb +3 -1
- data/lib/openstax/accounts/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: 3bbc4f9d4b0e45a223ac13d149012a2f27fc8ab8b77d71aa2213f447974ae0ee
|
4
|
+
data.tar.gz: fed8b3ecbf12bbd0cf45ca9f11a0e73a98c4a4157f97733ce3b2672ecb8bc7ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
13
|
+
loop do
|
14
|
+
response = OpenStax::Accounts::Api.get_application_account_updates
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
22
|
+
num_accounts = app_accounts.size
|
23
|
+
return if num_accounts == 0
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
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
|
-
|
43
|
+
OpenStax::Accounts::Api.mark_account_updates_as_read(updated_app_accounts)
|
38
44
|
|
39
|
-
|
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(
|
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".
|
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.
|
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-
|
11
|
+
date: 2020-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|