Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

last_connection actually returns the first connection. #246

Open
edlebert opened this issue Jan 10, 2023 · 1 comment
Open

last_connection actually returns the first connection. #246

edlebert opened this issue Jan 10, 2023 · 1 comment
Assignees

Comments

@edlebert
Copy link

It sorts the connections by ascending updatedAt, and takes the first one. I confirmed the behavior using the API code on my own organization, which has three connections. It always returned the oldest connection, not the connection that was just made.

The code currently is

connections.sort { |a,b| DateTime.parse(a['updatedDateUtc']) <=> DateTime.parse(b['updatedDateUtc'])}.first

But since the timestamps are ISO format, we can just sort them as strings, and take the last, so it should/could be

connections.sort { |a,b| a['updatedDateUtc'] <=> b['updatedDateUtc']}.last
@pumpkinball pumpkinball self-assigned this Jan 24, 2023
@pumpkinball
Copy link
Contributor

Hi @edlebert thank you for picking this up.
I've tested and made the change locally, we're deploying a few things next week to the xero-ruby SDK, so this change will be added in at the same time.

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

No branches or pull requests

2 participants