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: show correct badge count on notebook button #17735

Merged
merged 211 commits into from
Oct 24, 2023

Conversation

daibhin
Copy link
Contributor

@daibhin daibhin commented Oct 3, 2023

Problem

Reported in https://posthog.slack.com/archives/C05N9R3HT7V/p1695922124646429. The badge was showing the count for all the notebooks containing an insight, and not making use of the saved insights id

Changes

  • Pass the saved insights id to the NotebookSelectButton
  • Use a special id_match_structure to find matching insights

How did you test this code?

Updated tests

@daibhin daibhin marked this pull request as ready for review October 3, 2023 13:00
@daibhin daibhin requested a review from pauldambra October 3, 2023 13:00
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

4 snapshot changes in total. 0 added, 4 modified, 0 deleted:

  • chromium: 0 added, 4 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

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

🙌

@daibhin daibhin force-pushed the dn-fix/insight-notebook-badge branch from 27559ae to f95d65a Compare October 3, 2023 15:28
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

4 snapshot changes in total. 0 added, 4 modified, 0 deleted:

  • chromium: 0 added, 4 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@@ -281,6 +281,8 @@ def _filter_request(self, request: request.Request, queryset: QuerySet) -> Query
# replay timestamps are not at the top level, they're one-level down in a content array
presence_match_structure = [{"content": [{"type": f"ph-{target}"}]}]
id_match_structure = [{"content": [{"attrs": {"sessionRecordingId": match}}]}]
elif target == "query":
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 So we are making query only work for a specific Insight? This feels very off...

If this is the way to go then I think the "target" should explicitly be saved-insight or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding was that this is just for cases in which there is an id present e.g. when the search query looks like query:vk7xz3 where the content after the colon is the short id of the saved insight. You could still search notebooks that contain / do not contain queries with the search param query:true or query:false.

The only reason we special case this lookup is because the NotebookNodeQuery does not have an id attribute which the search endpoint assumes. Its id is nested inside the query attribute.

Does that explain your question?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pauldambra am I right in thinking that this will still allow you to search for the presence of a query with the query:true param?

Copy link
Member

Choose a reason for hiding this comment

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

so long as this test is still valid

        # filter by insight
        insight_filter_response = self.client.get(f"/api/projects/{self.team.id}/notebooks?contains=query:true")
        assert [n["id"] for n in insight_filter_response.json()["results"]] == [insight_content_notebook]

then yep we can filter by presence of "type" and presence of an instance of a "type"

@daibhin daibhin force-pushed the dn-fix/insight-notebook-badge branch from b239c96 to bb08774 Compare October 9, 2023 10:41
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

4 snapshot changes in total. 0 added, 4 modified, 0 deleted:

  • chromium: 0 added, 4 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

robbie-c and others added 13 commits October 23, 2023 14:36
…17850)

* Fix top pages SQL

* Use person id for now

* Add limits to web analytics queries

* Add some trends to web analytics

* Tweak query date ranges and formatting

* Consistently use person_id for now
* move onstart to products page

* remove product intro

* include stepkey as prop

* redo how navigation works

* go back to products if first step

* fix url redirect loop

* fix jitteryness with otherproductsstep

* fix grumpy linting
#17820)

* chore(plugin-server): kafka: change analytics linger.ms and batch.size for all producers

* add envvars
* Increase playwright timeouts

* Tidy up comments
raquelmsmith and others added 23 commits October 23, 2023 14:42
* feat(hogql): mixed poe mode

* schema
* chore(hogql): Use the C++ parser in local dev

* Update all the parsing functions, not just `parse_select`
…8101)

* Added support for daily and weekly active user aggregations

* Removed unused join

* Fixed tests and applied Sample placeholders

* Fixed formula running on an empty string

* Updated the name of QueryModifier

* Comments and fixed name casing
* WIP

* Kinda sorta working

* Add dashboard filters to cache key

* Make mypy happy

* Add support for properties

* Use get_query_runner

* Add tests for dashboard_query

* Add tests for merging of filters

* Add test for hash when dashboard filters are applied

* Silently accept having no valid query runner

* Remove index type from DashboardFilter

* Fix type of dashboard_query

* Fix test typing
…d cells (#18116)

* Add better table formatting

* Use QueryContent to right-align table cells and headings

* Just use toLocaleString
#18120)

fix(plugin-server): prevent multiple concurrent reloadPlugins and coalesce them when possible
* opt in surveys when creating survey and opt out when no active surveys

* update survey banner warning

* add auto opt ins for surveys list launch and stop surveys

* remove from onboarding step

* Update UI snapshots for `chromium` (2)

* update opt in from backend instead

* add filter for api surveys and post delete to receiver

* Update query snapshots

* fix popup flicker

* ambr snapshots

* disabled popup banner rename

* exclude api surveys in query instead

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* pay gates wip

* Update UI snapshots for `chromium` (2)

* pay gate survey edit

* html descriptions

* Update UI snapshots for `chromium` (2)

* rename ctas in pay gate mini and use getavailablefeature

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `webkit` (2)

* feature flag pay gate

* Update UI snapshots for `chromium` (2)

* swap surveys beta tag for new and bump higher

* Update UI snapshots for `chromium` (1)

* fix merge conflict

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
…te (#18125)

* move survey question type back up

* add open feedback template

* fix description
* only run hogql parser workflow if running from upstream repo

* Fix capitalization

---------

Co-authored-by: Michael Matloka <[email protected]>
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.18 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](postcss/postcss@8.4.18...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

4 snapshot changes in total. 0 added, 4 modified, 0 deleted:

  • chromium: 0 added, 4 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

👍 still has the issue of only really working for insight queries but i can live with that for now

@posthog-bot posthog-bot removed the stale label Oct 24, 2023
@daibhin daibhin merged commit 6859c72 into master Oct 24, 2023
74 checks passed
@daibhin daibhin deleted the dn-fix/insight-notebook-badge branch October 24, 2023 08:17
Justicea83 pushed a commit to Justicea83/posthog that referenced this pull request Oct 24, 2023
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.