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

Partition Metrics - Access nested JSON Field #6498

Closed
bkhkcm opened this issue Aug 13, 2024 · 3 comments
Closed

Partition Metrics - Access nested JSON Field #6498

bkhkcm opened this issue Aug 13, 2024 · 3 comments
Assignees
Labels
bug Verified bug by the Nova team next
Milestone

Comments

@bkhkcm
Copy link

bkhkcm commented Aug 13, 2024

  • Laravel Version: ^10.0
  • Nova Version: 4.26.5
  • PHP Version: 8.2.4
  • Database Driver & Version: pdo_mysql, mysqlnd 8.2.4

Description:

In my partition metric I want to access a nested JSON field.

public function calculate(NovaRequest $request) {
  return $this->count($request, User::class, 'meta->notifications->newsletters');
}

However, I don't get any correct data back.

Screenshot 2024-08-13 at 13 55 50

If I make a query directly to the database:

SELECT JSON_UNQUOTE(JSON_EXTRACT(meta, '$.notifications.newsletters')) AS opt, COUNT(*) as aggregate FROM users GROUP BY opt;

Do I get the following data:

opt aggregate
true 58
false 13
NULL 1
@bkhkcm
Copy link
Author

bkhkcm commented Aug 13, 2024

It seems that in the file /vendor/laravel/nova/src/Metrics/Partition.php, when calling the function formatAggregateResult, an empty string is passed for $key.

@jeremynikolic jeremynikolic self-assigned this Aug 16, 2024
@jeremynikolic jeremynikolic added pending Issues that are pending triage fix incoming A fix is in review and removed pending Issues that are pending triage labels Aug 16, 2024
@crynobone crynobone added this to the 5.x milestone Aug 20, 2024
@crynobone crynobone added bug Verified bug by the Nova team next and removed fix incoming A fix is in review labels Aug 20, 2024
@jeremynikolic jeremynikolic added the fix incoming A fix is in review label Aug 21, 2024
@crynobone crynobone removed the fix incoming A fix is in review label Aug 23, 2024
@crynobone
Copy link
Member

Released with Laravel Nova 5.0.0

Feel free to open up a new issue if you're still experiencing this problem on the latest version.

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified bug by the Nova team next
Projects
None yet
Development

No branches or pull requests

3 participants