nova-issues icon indicating copy to clipboard operation
nova-issues copied to clipboard

Partition Metrics - Access nested JSON Field

Open bkhkcm opened this issue 6 months ago • 1 comments

  • 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 avatar Aug 13 '24 12:08 bkhkcm