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

feat(3000): Add automatic "Load more" #15863

Merged
merged 18 commits into from
Jun 9, 2023
Merged

feat(3000): Add automatic "Load more" #15863

merged 18 commits into from
Jun 9, 2023

Conversation

Twixes
Copy link
Member

@Twixes Twixes commented Jun 2, 2023

Problem

A bunch of our lists are paginated server-side (like insights) or just have "Load more" (like persons), but neither was supported in the sidebar yet, and neither approach would even work smoothly in a sidebar.

Changes

Fortunately, react-virtualized has awesome building blocks for virtualized lists with just-in-time loading, which provide a really good experience for even the largest collections. So that's how we now handle items that are paginated/"Load more"'d in table format.

2023-06-02 11 21 47

@Twixes Twixes requested a review from thmsobrmlr June 2, 2023 09:23
@Twixes Twixes changed the title feat(3000): Add autoloading for insights feat(3000): Add automatic "Load more" Jun 2, 2023
Copy link
Contributor

@thmsobrmlr thmsobrmlr left a comment

Choose a reason for hiding this comment

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

The infinite search is suuuuuper smooth. Also can't find anything else to complain about and can go in aside from one concern of mine: I think the f"SELECT count() FROM ({total_query})" would be slow for projects with a lot of persons (it'd need to check all active parts?) - did you try running this in production or have better knowledge than me and know this is quick?

actor_ids = [row[0] for row in raw_paginated_result]
_, serialized_actors = get_people(team, actor_ids)

total_query, total_params = person_query.get_query(paginate=False, filter_future_persons=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not something we need to fix now, but the persons endpoint and how we paginate here feels very bespoke. Would be great to have the right abstractions in place for a common thing like pagination.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, though here this gets a bit tricky because its ClickHouse – no ORM involved

_, serialized_actors = get_people(team, actor_ids)

total_query, total_params = person_query.get_query(paginate=False, filter_future_persons=True)
total_query_aggregated = f"SELECT count() FROM ({total_query})"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd think this query would be slow for projects with a lot of persons (it'd need to check all active parts?) - did you try running this in production or have better knowledge than me and know this is quick?

Copy link
Member Author

Choose a reason for hiding this comment

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

I ran it for out project but indeed for some larger ones it takes a few seconds, which is not ideal… I think when we fully release this the solution will have to be we'll only load the total count once, but for now just put this behind a URL param that's only used in PostHog 3000.

@Twixes Twixes mentioned this pull request Oct 19, 2023
41 tasks
@Twixes Twixes merged commit c0dc654 into master Jun 9, 2023
@Twixes Twixes deleted the posthog-3000-load-more branch June 9, 2023 13:58
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.

2 participants