Skip to content

WIP: beta branch collapse#67

Open
kimburgess wants to merge 2175 commits intomasterfrom
beta
Open

WIP: beta branch collapse#67
kimburgess wants to merge 2175 commits intomasterfrom
beta

Conversation

@kimburgess
Copy link
Copy Markdown
Contributor

Merges the 'working copy' of this repo back into master in order to consolidate development ahead of implementation on new simplified branching structure and review process.

Currently awaiting merge of other active changes prior to review.

Copy link
Copy Markdown
Contributor Author

@kimburgess kimburgess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perf comments on old office lib

Comment thread lib/microsoft/office.rb
data = data.to_json if !data.nil? && data.class != String

if password
headers['Authorization'] = "Bearer #{password_graph_token}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This performs an OAuth token request (possible secondary point of rate limiting) prior to the actual graph request taking place. Caching tokens should help reduce request overhead / number of round trips needed.

Comment thread lib/microsoft/office.rb
if password
headers['Authorization'] = "Bearer #{password_graph_token}"
else
headers['Authorization'] = "Bearer #{graph_token}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here

Comment thread lib/microsoft/office.rb
graph_api = UV::HttpEndpoint.new(@graph_domain, graph_api_options)
response = graph_api.__send__(request_method, path: graph_path, headers: headers, body: data, query: query)

start_timing = Time.now.to_i
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used anywhere (possible left over from some debug logging)?

Comment thread lib/microsoft/office.rb

start_timing = Time.now.to_i
response_value = response.value
end_timing = Time.now.to_i
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here

Comment thread lib/microsoft/office.rb

def check_response(response)
case response.status
when 200, 201, 204
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a range for 200-ish response (e.g. when 200..299) will catch all generally ok responses.

Comment thread lib/microsoft/office.rb
raise Microsoft::Error::ErrorAccessDenied.new(response.body)
when 404
raise Microsoft::Error::ResourceNotFound.new(response.body)
end
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graph API returns 429's in the case of rate limiting. It's worth handling that explicitly here.

Comment thread lib/microsoft/office.rb
when 404
raise Microsoft::Error::ResourceNotFound.new(response.body)
end
end
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other response codes are currently silently swallowed. Worth adding an else condition for these.

Comment thread lib/microsoft/office.rb
endpoint = "/v1.0/users"
request = graph_request(request_method: 'get', endpoint: endpoint, query: query_params, password: @delegated)
check_response(request)
user_list = JSON.parse(request.body)['value']
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on response sizes, it may be worth handing this off to a threadpool.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto for all other occurrences of JSON.parse

Comment thread lib/microsoft/office.rb
'$filter': "createdDateTime gt #{created_from}"
}

bulk_response = bulk_graph_request(request_method: 'get', endpoints: endpoints, query: query )
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call is synchronous (due to co-routine / awaiting response). This may be intended, but if not, this slicing / loop could be refactored to query each slice in parallel.

Comment thread lib/microsoft/office.rb

event = event.to_json

event.gsub!("X!X!X!",description)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be inserted directly into attributes that need the substitution before stringifying to JSON? Should cut down the amount of string manipulation needed.

w-le and others added 29 commits October 31, 2019 14:31
w-le and others added 30 commits September 23, 2020 13:34
… Ignore power query response (it's always 'false')
chore(pexip) update system_location
Attempt to resolve build error:

```
Bundler could not find compatible versions for gem "ruby":
  In Gemfile:
    ruby

    aca-device-modules was resolved to 2.0.0, which depends on
      ruby (>= 2.3.0)

    aca-device-modules was resolved to 2.0.0, which depends on
      orchestrator was resolved to 2.0.0, which depends on
        rails (~> 6.0) was resolved to 6.1.7.8, which depends on
          ruby (>= 2.5.0)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants