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

fix: members query in account set #165

Merged
merged 9 commits into from
Jul 12, 2024
Merged

Conversation

thevaibhav-dixit
Copy link
Contributor

@thevaibhav-dixit thevaibhav-dixit commented Jul 11, 2024

We were comparing created_at in cala_account_set_member_account_sets and cala_account_set_member_accounts with cursor created form created_at in cala_account_sets and cala_accounts!

@thevaibhav-dixit thevaibhav-dixit changed the title Fix list children query fix: members query in account set Jul 11, 2024
@vindard
Copy link
Contributor

vindard commented Jul 11, 2024

Just did some testing with this branch. This is still pretty broken. It's grouping Accounts and then AccountSets in the returned list (sorted by cursor within each group).

For e.g, I'm getting (with time as proxy for cursor ordering):

  • Account @ Time 6
  • Account @ Time 4
  • Account @ Time 2
  • AccountSet @ Time 5
  • AccountSet @ Time 3
  • AccountSet @ Time 1

And if I paginate after Account @ Time 4 I'll get:

  • Account @ Time 2
  • AccountSet @ Time 3
  • AccountSet @ Time 1

We should probably figure out a way to test expected ordering as well

@vindard
Copy link
Contributor

vindard commented Jul 11, 2024

I just added a branch to help with testing pagination. It seeds a list of accounts/accountSets under a chart of accounts account set that we can test pagination through

https://github.com/GaloyMoney/cala/compare/test-pagination

To initialize:

  • make reset-deps run-server
  • In a separate terminal make run-tf

To test, get the full list with this query, and then in a new tab choose different items to paginate from

{
  accountSet(id: "00000000-0000-0000-0000-100000000000") {
    name
    members(first: 100) {
      edges {
        cursor
        node {
          ... on Account {
            __typename
            id
            name
          }
          ... on AccountSet {
            __typename
            id
            name
          }
        }
      }
    }
  }
}

The bug

After drilling in further with this, the bug I found was that if you try to paginate from an AccountSet specifically (e.g. (AccountSet #7) Withdrawals Control), it will not show its immediate neighbouring AccountSet. It will show all accounts after it, and all AccountSets after it that aren't its immediate neighbour.

@thevaibhav-dixit
Copy link
Contributor Author

Just did some testing with this branch. This is still pretty broken. It's grouping Accounts and then AccountSets in the returned list (sorted by cursor within each group).

For e.g, I'm getting (with time as proxy for cursor ordering):

  • Account @ Time 6
  • Account @ Time 4
  • Account @ Time 2
  • AccountSet @ Time 5
  • AccountSet @ Time 3
  • AccountSet @ Time 1

And if I paginate after Account @ Time 4 I'll get:

  • Account @ Time 2
  • AccountSet @ Time 3
  • AccountSet @ Time 1

We should probably figure out a way to test expected ordering as well

is this not the expected behaviour ? we are getting all the accounts/ account sets that were created before Time @ 4

@vindard
Copy link
Contributor

vindard commented Jul 11, 2024

is this not the expected behaviour ? we are getting all the accounts/ account sets that were created before Time @ 4

There's no concept of time in the end-user pagination interface I think, we just use that as an implementation detail to do our ordering. If I was looking at the first list and paginating from Time 4 I would expect all items under it in the page, and ordered in the order the page was first presented:

  • Account @ Time 2
  • AccountSet @ Time 5
  • AccountSet @ Time 3
  • AccountSet @ Time 1

But to be more correct (like it currently is on main) I would expect the original list to actually be ordered like:

  • Account @ Time 6
  • AccountSet @ Time 5
  • Account @ Time 4
  • AccountSet @ Time 3
  • Account @ Time 2
  • AccountSet @ Time 1

And if I paginated from Time 4 I'd expect the following in the order presented:

  • AccountSet @ Time 3
  • Account @ Time 2
  • AccountSet @ Time 1

@thevaibhav-dixit thevaibhav-dixit force-pushed the fix-list-children-query branch from 8e924ac to 1792d34 Compare July 11, 2024 16:07

for row in rows.into_iter() {
if let Some(member_account_id) = row.member_account_id {
account_ids.push((
Copy link
Member

Choose a reason for hiding this comment

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

why not instantiate the proper type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i was not sure if we could sort the struct... But can try that

@thevaibhav-dixit thevaibhav-dixit force-pushed the fix-list-children-query branch from 06cdab7 to 86ac85e Compare July 12, 2024 08:55
@thevaibhav-dixit thevaibhav-dixit force-pushed the fix-list-children-query branch from 9bedd21 to 6a1bb3c Compare July 12, 2024 10:23
);

let after_cursor = AccountSetMemberCursor {
member_created_at: ret.entities[0].created_at,
Copy link
Member

Choose a reason for hiding this comment

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

doesn't ret have the cursor? Why construct it>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes it does have an end cursor. here i am creating cursor using the first element to better test

@@ -20,3 +20,9 @@ impl From<&AccountSetValues> for AccountSetByNameCursor {
pub struct AccountSetMemberCursor {
pub member_created_at: chrono::DateTime<chrono::Utc>,
}

impl From<chrono::DateTime<chrono::Utc>> for AccountSetMemberCursor {
Copy link
Member

Choose a reason for hiding this comment

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

This should be from a domain type to another not from a primitive. so From<AccountSetMember>

@thevaibhav-dixit thevaibhav-dixit merged commit 373a85c into main Jul 12, 2024
5 checks passed
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.

3 participants