SRGSSR / pillarbox-web

Pillarbox is a versatile media playback ecosystem engineered for the web.
https://srgssr.github.io/pillarbox-web-demo/
MIT License
11 stars 1 forks source link

Evaluating an alternative diagnostic tool #168

Closed amtins closed 4 months ago

amtins commented 7 months ago

As a Pillarbox developer, I'd like to evaluate the possibility of harvesting player-related data in order to have a fully customizable diagnostic tool.

Acceptance Criteria

amtins commented 4 months ago

Snitch storage alternative

This investigation aims to test the collection of diagnostic data using PocketBase.

PocketBase

PocketBase is an open source Go backend, consisting of:

Benefits

Drawbacks

Material and Cost

Server

Link to the server configuration SYS-4-SSD-16

Configuration

Omitted

Cost

Price per month 22.99€ plus installation fee 22.99€ which equals to 298.87€ annually.

End points

Omitted

Improvements

Today, data is stored in a JSON field, which slows down SQL queries and index creation.

Several approaches are possible:

  1. Extract fields as needed and leave the rest in a JSON object. This will require updating the extracted fields to keep the data consistent.
  2. Create a table containing all fields, where each value represents the value of each JSON object. We might be tempted to normalize the database in 3NF, but this would bring no benefit and would require queries with joins.

The advantage of either solution is that it would be possible to create indexes according to need, to speed up queries.

The data migration script could look like this:

INSERT INTO reports (
  `id`,
  `updated`,
  `created`,
  `PlayerDuration`,
  `PlayerUrl`,
  `browser`,
  `clientTime`,
  `device`,
  `drmDuration`,
  `drmUrl`,
  `duration`,
  `environment`,
  `ilDuration`,
  `ilHttpStatusCode`,
  `ilNoPlayableResourceFound`,
  `ilPlayableAbroad`,
  `ilUrl`,
  `networkType`,
  `platform`,
  `player`,
  `referrer`,
  `screenType`,
  `tokenDuration`,
  `tokenHttpStatusCode`,
  `tokenUrl`,
  `urn`
)
SELECT
  id,
  created,
  updated,
  coalesce(json_extract(report, '$.playerResult.duration'),'n/a'),
  coalesce(json_extract(report, '$.playerResult.url'),'n/a'),
  coalesce(json_extract(report, '$.browser'),'n/a'),
  coalesce(json_extract(report, '$.clientTime'),'n/a'),
  coalesce(json_extract(report, '$.device'),'n/a'),
  coalesce(json_extract(report, '$.drmResult.duration'),'n/a'),
  coalesce(json_extract(report, '$.drmResult.url'),'n/a'),
  coalesce(json_extract(report, '$.duration'),'n/a'),
  coalesce(json_extract(report, '$.environment'),'n/a'),
  coalesce(json_extract(report, '$.ilResult.duration'),'n/a'),
  coalesce(json_extract(report, '$.ilResult.httpStatusCode'),'n/a'),
  coalesce(json_extract(report, '$.ilResult.noPlayableResourceFound'),'n/a'),
  coalesce(json_extract(report, '$.ilResult.playableAbroad'),'n/a'),
  coalesce(json_extract(report, '$.ilResult.url'),'n/a'),
  coalesce(json_extract(report, '$.networkType'),'n/a'),
  coalesce(json_extract(report, '$.platform'),'n/a'),
  coalesce(json_extract(report, '$.player'),'n/a'),
  coalesce(json_extract(report, '$.referrer'),'n/a'),
  coalesce(json_extract(report, '$.screenType'),'n/a'),
  coalesce(json_extract(report, '$.tokenResult.duration'),'n/a'),
  coalesce(json_extract(report, '$.tokenResult.httpStatusCode'),'n/a'),
  coalesce(json_extract(report, '$.tokenResult.url'),'n/a'),
  coalesce(json_extract(report, '$.urn'),'n/a')
FROM snitch;

Finally, it's important to add indexes to the created and updated fields so that the admin interface isn't slow to load when the database starts to contain several million entries.

amtins commented 4 months ago

I'll contact Play Suisse for an Npaw demo.