Junior — Senior
Counting the recurrence of unique combinations of event name and user
livecode
Task condition
It is necessary to determine how often individual unique combinations of the fields "title" and "user_id" occur in the array of events. For each such combination, count the number of its occurrences.
{
"events": [
{
"time": "2022-06-17 08:54:03",
"title": "search",
"user_id": null,
"ref": "main",
"session_id": "a2"
},
{
"time": "2022-06-17 23:19:33",
"title": "main",
"user_id": null,
"ref": null,
"session_id": "b4"
},
{
"time": "2022-06-20 13:02:44",
"title": "success",
"user_id": null,
"ref": "seats",
"session_id": "b1"
},
{
"time": "2022-06-20 14:45:43",
"title": "search_click",
"user_id": 123,
"page": "main",
"session_id": "a1"
},
{
"time": "2022-06-20 14:46:49",
"title": "main",
"user_id": 123,
"ref": null,
"session_id": "a1"
},
{
"time": "2022-06-17 23:21:31",
"title": "search",
"user_id": null,
"ref": "main",
"session_id": "b5"
},
{
"time": "2022-06-18 13:02:44",
"title": "main",
"user_id": null,
"ref": "seats",
"session_id": "c2"
},
{
"time": "2022-06-18 14:47:03",
"title": "seats",
"user_id": 123,
"ref": "search",
"session_id": "d1"
},
{
"time": "2022-06-18 13:12:41",
"title": "search",
"user_id": null,
"ref": "seats",
"session_id": "c4"
},
{
"time": "2022-06-20 14:44:01",
"title": "chat_open",
"user_id": 123,
"page": "seats",
"session_id": "d1"
},
{
"time": "2022-06-20 14:46:32",
"title": "chat_send_message",
"user_id": 123,
"page": "seats",
"session_id": "d1"
},
{
"time": "2022-06-21 13:12:41",
"title": "seats",
"user_id": 34,
"ref": null,
"session_id": "c4"
},
{
"time": "2022-06-21 21:14:00",
"title": "success",
"user_id": null,
"ref": null,
"session_id": "b4"
}
]
}
The result should be a structure where the key is a string of the form "title|user_id", and the value is the count of its appearances in the original array.