Collecting and simulating events
Before we can get started aggregating and visualizing statistics, we first need to collect (and later simulate) events, which we are going to use to create the statistics. We will start by thinking about which data we want to collect, and which data would be useful for us. We will focus on post views for now, so we would like to show the following statistics per post:
- Total number of views on a post
- Daily views on a post
- Daily average viewing duration on a post
Let’s start by creating the database model for events that will allow us to show these statistics.
Creating the event model
To create these statistics, we need to collect events from users. Events will contain a reference to a post, a session ID to track events from the same viewing, an action (started viewing, ended viewing), and a date of when the event happened.
Let’s get started defining the database model for events:
- Copy the existing...