Grouping aggregate by day

0

I have a simple table log in a Postgres database that looks like this (simplified for the example):

time::timestamptz
action::varchar

time                          | action
2017-10-16 17:14:49.473903-08 | 'some action'
2017-10-16 17:14:49.473903-08 | 'some other action'
2017-10-17 17:14:49.473903-08 | 'some action'
//etc.

There are a variety of actions. I want to query this table to get one row per day with a column that contains an array of the counts of each action. This is the result I want:

day            actions
'2017-10-08' | [{"action":"some action", "count":10}, 
             |  {"action":"some other action", "count":20}}]
'2017-10-09' | [{"action":"some action", "count":15}, 
             |  {"action":"some other action", "count":18}}]

I can almost get there with this:

SELECT day, json_agg(act) as actions
FROM (
    SELECT action, time::date as day,  COUNT(*)
    FROM log_hits
    GROUP BY (action, day)
) act
GROUP BY day

This, of course, results in the date occurring in each the object in the actions array…

day           actions
'2017-10-08' | [{"action":"some action", day:"2017-10-08", "count":10}, 
             |  {"action":"some other action",  day:"2017-10-08", "count":20}}]

…which is redundant (and possible inefficient). What is the correct way to get the results grouped by day, with the day only occurring in its own column and the actions aggregate only being for that day?