Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Smart insights group support for combining time series with Top N

Open Jeehut opened this issue 2 years ago • 0 comments

Currently, we can either track the history of a specific event with a specific value for an attribute happening over time, or we can track the "Top N" values for a specific value for the last period of time. But what I often want to do is to track the history of each separate value of a given attribute over time.

This might sound a bit abstract, so let me give you a practical example. Currently, I'm tracking the popularity of my blog articles (http://fline.dev) by creating a new insight for every blog post I write and every time I create the same insight with one real change: I change the value of the route attribute to filter by. The result is something like this: Bildschirmfoto 2023-04-28 um 08 45 57

Creating a new insight for every value of the attribute is tedious though. And with this approach, I'm also lacking support to sort these insights by useful values, such as the number of page visits from the last 24 hours or 7 days, so I could easily find the most popular posts and see how their popularity changed over time in one place. One bar chart with so many different values simply doesn't do this useful data justice.

This might not only be useful for page visits, but all kinds of insights. So what I suggest is to create a new type of insight: A "Top-N Time Series" insight which shows up in the UI like a group but maybe a different icon, more like a "smart group". When I press on the group, I see all values that have at least a count of say 5 and their development over time. Editing this group of insights would only be possible with an "Edit" button on the "smart group" level, the automatically generated insights within the group wouldn't be editable directly. Instead, if I for example want to change the time series from the "line chart" mode to the "bar chart" mode, or if I want to change the time scale from "1 month daily" to "6 months monthly", I would just edit the "insight group" in one place and all automatic insights would be adjusted automatically.

There should also be an option to sort the auto-generated insights by different means. The default probably should be by the number of total event occurrences within the given time period. But there should also be options to sort by number of occurrences within the last 24 hours, 7 days, and 30 days. Additionally, a simple alphabetical sorting by the value could be useful. And lastly, it could be useful to also add sorting by "most recent first occurrence", so that I see my blog posts in their release order, showing the latest blog post at the top if I sort by that.

The sorting should probably be a setting right within the group page without me having to go into any edit mode of the insight group so that I can quickly change between different sortings.

Implementation Thoughts

From a technical perspective, actual insights could be generated by an async worker whenever a "smart group" is edited, plus another worker should check once a day if new insights came above the minimum values limit. But these insights could get marked with a "generated" bool so that the UI doesn't show any edit buttons for these insights. This way, only a new "smart group" type would need to be added. The UI for groups and insights could be reused as much as possible. When entering the edit mode of a "smart group", simply an insights editor could be shown but there could be a magic word like %values% that we set as the value for an attribute to specify which field should be used to generate the insights for. And maybe an additional text field to specify the minimum number of occurrences to generate a new insights could be needed.

Jeehut avatar Apr 28 '23 07:04 Jeehut