Best analytics logic to avoid many api calls

Hi @doug ,

For better performances, i don’t want to call each time i load a video thumbnail in my front application (in a video list for example), so i store the “lastAt” int in my db.

I want to update the “lastAt” property i stored in my db, for each video and user couple.

I want to execute, every x minutes, this process (via a cron) :

  • step 1 : in my db, get all media (“video” type), viewed last hour, and not present in my video_user_sessions table (api_video_id / user_id / api_video_session_id / loaded_at / ended_at)
  • step 2 : with this list of media containing a api_video_id, i call to get all analytic sessions for each video (api_video_id)
  • step 3 : i insert in my db, if not exist, each session data in my video_user_sessions table
  • step 4 : in my db, get all sessions not ended (video_user_sessions table)
  • step 5 : for each api_video_session_id, i call to get all session events and found the last “at” for update the lastAt field (for couple apiVideoId/userId) in my db
  • step 6 : delete sessions in my video_user_sessions table where endedAt < now

What do think about this process ? A better idea ?



I think you sent that text to the wrong person but it’s all good have a good day

I don’t think so, have a good day too :wink:


This approach seems pretty reasonable. We’d love suggestions on improvements (webhooks are on the roadmap).


Thank you for you opinion.

Webhooks are the best solution, so it’s a good news :slight_smile:

Any idea of a release ? (current month, next month, … ?)

It’s possible to know when webhooks will be in production ? (for my roadmap…)