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

Bug: Order of the bots on widget is incorrect #2244

Closed
zavreb opened this issue Apr 26, 2018 · 28 comments
Closed

Bug: Order of the bots on widget is incorrect #2244

zavreb opened this issue Apr 26, 2018 · 28 comments
Assignees

Comments

@zavreb
Copy link

zavreb commented Apr 26, 2018

This one is hard to reproduce since it requires movement of 3 users.

Issue per @mstidham:

The order of the bots on widget is incorrect. According to the screenshot below the bot "Pacific Desgin Center" should be to the left of "Home Presence" because it was the last visited bot.

- -
1. Account owner @scurry is a visitor for two bots Verve Coffee and Gracias Madre hence having You're Here works as expected, should be in Slot 1 & 2
2. User @becky entered bot Pacific Design Center. (making her the most recent bot visitor). Should be in Slot 3, but is in Slot 4 instead.
3. User @miranda had been at home all day. Has not made any movement. She is in Slot 3, but she should have been pushed to Slot 4 after @becky's visit to bot Pacific Design Center

See #1903 for older commentary

image

See req from #1903:

Req:

Geofence bots are ordered by most recent visits, the horizontal list should be real time updating from left (newest visitor) to right (oldest visitor), however, the You're Here bot does not get pushed to the right, they are statically in the first slot while the second slot updates with the newest bot

@mstidham
Copy link

mstidham commented Apr 26, 2018

How the test is done:

  1. "@miranda" has app open in the foreground and monitoring the widget.
  2. "@scurry" left the "Pacific Design Center" (the visitor count changed correctly) and walked to the "WeHo - Dog Park!"
  3. The "WeHo - Dog Park!" bot appears on widget and is aligned to the right of the "Pacific Design Center".
    The bot order is "Home Presence Test" (You're Here), "Pacific Design Center", "WeHo - Dog Park!"
  4. "@miranda" does a kill/reload and the bot order remains the same as above.

The bot order should be:
"Home Presence Test" (You're Here), "WeHo - Dog Park", then "Pacific Design Center"

Screenshot of "@miranda" Device with the app in the foreground.
image

@aksonov
Copy link
Contributor

aksonov commented Apr 27, 2018

I don't understand steps to reproduce. Who is logged/reported user? @scurry ? What is the app mode (foreground only/app refresh/first app run) ? Also it is VERY difficult for me to reproduce it - probably @southerneer could observe it/debug and fix in the LA office...

@bengtan
Copy link
Contributor

bengtan commented Apr 27, 2018

Assigning to @southerneer.

Please disambiguate and diagnose, and inform the rest of us what the diagnosis is.

(In addition to attempting to fix it, if possible.)

@aksonov
Copy link
Contributor

aksonov commented Apr 27, 2018

Eric, the good thing we could do first is to add separate tests (probably even separate file) for wocky.activeBots (with three active users) that will check both initial list retrieval of activeBots as well as live subscriptions - thanks to @bernardd the issue with subscription was solved and all subscription-related tests are passed well now (so we can safely add more!)

@aksonov
Copy link
Contributor

aksonov commented Apr 27, 2018

@bernardd, @toland Looks like User's 'active' bots (with GUEST relationship) are not retrieved with correct order (sorted by last visit date), how to do it?

Now we are using:

          user(id: $userId) {
            id
            bots(first: $max after: $after relationship: GUEST) {
              totalCount
              edges {
                cursor
                node {
                  ${BOT_PROPS}
                }
              }
            }
          }

@mstidham
Copy link

mstidham commented Apr 27, 2018

Bot Order when starting with a blank widget (@miranda removed footprints CTA from all bots on widget):

  1. Tapped footprints CTA on "Pacific Design Center", "Home Presence Test", "Home Sweet Home"
  2. The initial bot order on widget is the order I added the bots. (left screenshot)
  3. @miranda did a kill/reload of the app and the bot order changed.
  4. Bot order is now "Home Presence Test", "Pacific Design Center", "Home Sweet Home" (right screenshot)

snip20180427_71

@aksonov
Copy link
Contributor

aksonov commented Apr 27, 2018

Okey, so live updates probably work.
Initial list order is wrong

@toland
Copy link
Contributor

toland commented Apr 27, 2018

@aksonov:

Looks like User's 'active' bots (with GUEST relationship) are not retrieved with correct order (sorted by last visit date), how to do it?

We don't do any explicit sorting on the bots returned by the bots connection. I could be wrong, but I don't recall anyone asking us for explicit sorting. The current database schema was not designed with this in mind. Right now, getting the last visit time for a particular user to a particular bot is a very complicated (and correspondingly expensive) query. If this kind of sorting is a requirement, then we will need to think about denormalizing the data a bit to make this query more reasonable.

Also, there is an important caveat when sorting guests by the last visit time. It is likely that some large percentage of the guests have not visited a bot yet, so the best we could do is to return the users who have visited a bot first, in chronological order of visit, with the rest of the list being unsorted.

Reading over the rest of the ticket, it looks like what you really want is visitors. Guests are subscribers who have agreed to share their location with the other guests in this bot. Visitors are guests who are currently inside the perimeter of the bot. You can retrieve visitors with the same query and substituting VISITOR for GUEST. This doesn't solve the sorting issue, which still requires back-end work.

I have opened a server-side ticket to implement sorting by visit time at hippware/wocky#1474.

@thescurry
Copy link

Also, there is an important caveat when sorting guests by the last visit time. It is likely that some >large percentage of the guests have not visited a bot yet, so the best we could do is to return the >users who have visited a bot first, in chronological order of visit, with the rest of the list being >unsorted.

Phil, you broke my brain with this comment, I can't figure out what you're saying. :) Let's sync up later on Slack.

@thescurry
Copy link

Phil and I synced up on Slack... think we are all on the same page now. 👍

@toland
Copy link
Contributor

toland commented Apr 27, 2018

OK, after syncing with Steve, and rereading the ticket several times, I am realizing that I was confused. Ignore most of what I said in my previous comment (though the part clarifying the terms "guest" and "visitor" is still relevant).

@aksonov

Looks like User's 'active' bots (with GUEST relationship) are not retrieved with correct order (sorted by last visit date), how to do it?

I am not sure that I understand what you are asking for here. Part of the problem is the term "active" bots. What does that mean? You said you want bots with a GUEST relationship, but then you said you want them sorted by visit time, which makes it sound like you actually want VISITORs.

Unless you mean that you want bots that a user is a GUEST of sorted by the last time anyone has visited them. If so, how could this possibly be the "correct" order to always return bots in? Surely we don't want to make that the default sort order. Do we? Also, if that is the case, don't you also want to know the last user that visited the bot?

Based on my current understanding of how the widget is supposed to work, I don't understand how you are using the query you posted and what you want from it.


As a side note on that query, I assume that you are querying for bots associated with the currently logged in user. If so, please don't use user(id: ...) {}. When querying for details about the currently logged in user, always use currentUser {}. The two queries are not equivalent, even if you pass the id of the currently logged in user to the first query.

@aksonov
Copy link
Contributor

aksonov commented Apr 28, 2018

@toland The app needs to show 'active' bots - bots where logged user is 'GUEST' and it has non-zero number of visitors. And this list must be sorted by latest visitor time. Yes, a list of all visitors (or at least latest 5) for each bot is necessary as well.

Noted about currentUser.

cc @southerneer

@bernardd
Copy link

We don't do any explicit sorting on the bots returned by the bots connection. I could be wrong, but I don't recall anyone asking us for explicit sorting

Not quite true. All the GraphQL queries are, by default, sorted by update time on the object (newest to oldest). No reason for this other than that it made more sense than database ordering. The only exception is one of the collections queries which was specced to be ordered a different way.

@toland
Copy link
Contributor

toland commented Apr 30, 2018

The app needs to show 'active' bots - bots where logged user is 'GUEST' and it has non-zero number of visitors. And this list must be sorted by latest visitor time. Yes, a list of all visitors (or at least latest 5) for each bot is necessary as well.

OK. I think this requires a new connection on currentUser. I think something like this:

{
  currentUser {
    activeBots(first: 10) {
      edges {
        node {
          id
          description
          image {
            thumbnailUrl
          }
          subscribers(first: 5, type: VISITOR) {
            edges {
              node {
                id
                handle
              }
            }
          }
        }
      }
    }
  }
}

The activeBots connection would be sorted by latest visit time and I would change the subscribers connection on Bot so that if type is VISITOR then the default sorting would be by visit time.

@aksonov Please let me know if this looks acceptable. It is a fairly significant change on the backend and will take me another day or two to code and test.

@aksonov
Copy link
Contributor

aksonov commented Apr 30, 2018 via email

@toland
Copy link
Contributor

toland commented Apr 30, 2018

Looks OK

I have updated the ticket at hippware/wocky#1474. I am working on this feature now and should be done around mid-week.

@aksonov
Copy link
Contributor

aksonov commented May 4, 2018

My today changes should fix initial active bot list order and live updates order. However visitor list after viewing of "Visitors" UI may still be incorrect (because it uses XMPP query).

@southerneer Please work on #2281 to solve this issue.

@mstidham
Copy link

mstidham commented May 7, 2018

I'm assuming that no one has left/arrived at the PDC since Friday. Steve arrived at "Machine's Florida Compound" this weekend and I have received push notifications for arrival/exit so the bot "Machine's Florida Compound" should be to the left of "Pacific Design Center".

image

@aksonov
Copy link
Contributor

aksonov commented May 7, 2018 via email

@mstidham
Copy link

mstidham commented May 7, 2018

It worked perfectly on bypass account Testy Tester.

image

@mstidham
Copy link

mstidham commented May 8, 2018

I was just able to reproduce this on a new bypass account. @heavy (126-1160).

  1. @miranda left "The Stidham Residence" and returned to "The Stidham Residence"
  2. @heavy received the push notification of the exit/arrival with the app in the background.
  3. @heavy pulled the app to the foreground and the widget refreshed and the bot order is incorrect.
  4. @heavy should see "The Stidham Residence" on the far left then "Machine's Florida Compound" and on the far right should be "Pacific Design Center"
  5. Kill/reload does not change the results.

image

@aksonov
Copy link
Contributor

aksonov commented May 8, 2018

@mstidham Thanks for bypass! Please check my codepush (also check mentioned tickets)

@mstidham
Copy link

mstidham commented May 8, 2018

Codepush Verified Staging-Pavel "#2225, #2248, #2244

1 similar comment
@zavreb
Copy link
Author

zavreb commented May 8, 2018

Codepush Verified Staging-Pavel "#2225, #2248, #2244

@mstidham
Copy link

Verified on Staging Version: 2.6.3

1 similar comment
@zavreb
Copy link
Author

zavreb commented May 14, 2018

Verified on Staging Version: 2.6.3

@mstidham
Copy link

Verified on Production Version: 2.6.7

1 similar comment
@zavreb
Copy link
Author

zavreb commented May 17, 2018

Verified on Production Version: 2.6.7

@zavreb zavreb closed this as completed May 17, 2018
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

8 participants