Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add playlists to sync code, DB & API and add playlist direct links #1159

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Commits on Jun 3, 2024

  1. Add playlists to DB and harvest module

    This means that Tobira will store all playlist info already when
    syncing.
    
    I thought about the DB "array vs. table" question for some time. Here
    are my notes that made me decide for the array solution:
    
    
    Should the entries be stored as an array in a column of the `playlists`
    table? Or be a separate table that needs to be joined? The latter would
    be the traditionally "better" version, as it normalizes the data.
    
    A playlist entry contains these fields: 
    - Opencast ID, 
    - Type (e.g. video)
    - Content ID (e.g. Opencast video ID). 
    
    If we store it in a separate table we also need the following fields:
    - Playlist: foreign key to playlist ID
    - Index: ordering in a table is not well defined, so to get a definite
      order, we need another index field.
    - Potentially another artificial ID?
    
    
    
    - Normalization is what you're supposed to do, right?
    - Allows to use LIMIT and OFFSET, i.e. only load part of all entries.
      (Kind of possible with arrays as well though).
    - Allows to modify/delete individual entries without rewriting all of
      them
    
    - Many situations treat the entries as one atomic value:
        - Harvest/sync: the API sends the full playlist object including
          entries. If using an extra table, we would have to delete all old
          entries there, then insert all new ones.
        - Playlist block: loads all entries. Ok but what about pagination:
          we don't have that yet. But we should at some point? 
        - Even in the modifying/moving/deleting a single entry case: 
            - Opencast's APIs require us to send all entries, so while we
              can do very localized updates in our DB, we have to load all
              entries anyway.
            - After changing something, the Harvest API will send an update
              which leads to overwriting all entries again.
    - Extra table requires at least two additional fields to be stored
      (foreign key & index)
    - Management of `index` adds complexity whenever somehow editing
      entries. Just writing all entries at once again is easier. Also:
      should there be DB checks that make sure the indices are always 0 to
      N like for blocks? Adds more complexity and we ran into problems with
      that once.
    - Even if we add pagination: apart from offering a different UX,
      pagination helps with performance in four spots: rendering,
      backend<->frontend communication, DB<->backend communication, DB
      loading from disk. The first three benefits we can still have, even
      with arrays.
    - Looking at how PostgreSQL stores rows, arrays shouldn't incur any
      meaningful overhead and might even be faster in the majority of
      situations.
    LukasKalbertodt committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    a5640d1 View commit details
    Browse the repository at this point in the history
  2. Fix db clear after adding playlist types

    We did not have types depending on other types before. Adding "cascade"
    luckily fixes this.
    LukasKalbertodt committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    ca39d98 View commit details
    Browse the repository at this point in the history
  3. Split blocks/Series.tsx into two files

    I only moved stuff around and fixed imports, that's all. I did that so
    that the reviewer can just skip this commit. It is preparation for
    making a general `VideoListBlock`.
    LukasKalbertodt committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    e4137e9 View commit details
    Browse the repository at this point in the history
  4. Refactor VideoListBlock to be more independent of "series"

    Again, preparation for using that for playlists as well
    LukasKalbertodt committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    5ae7896 View commit details
    Browse the repository at this point in the history
  5. Remove unused order parameter from Series.events

    This was added a long time ago. By now, the ordering is done in the
    frontend, so the parameter is completely unused. We can get rid of some
    complexity by removing it.
    LukasKalbertodt committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    29fe59f View commit details
    Browse the repository at this point in the history
  6. Add playlists to GraphQL API

    This only adds querying capabilities, no mutations yet.
    LukasKalbertodt committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    c276b48 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    d29530c View commit details
    Browse the repository at this point in the history
  8. Improve warning when harvest item cannot be deserialized

    This is a band aid fix and not perfect. When I added the `Unknown`
    variant to the enum, I wasn't aware that it was used when other variants
    fail to deserialize even with `kind: "event"`. So the warning there
    was misleading.
    
    It's still not perfect because I ideally want to print more information
    on the deseralization failure. And the `kind` strings are duplicated
    now. I think in the future, the `HarvestResponse` might have items of
    type `{ kind: String, #[serde(flatten)] body: serde_json::Value }` or
    something like that. And then we deserialize it manually in a second
    step. We will see.
    LukasKalbertodt committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    3244bc0 View commit details
    Browse the repository at this point in the history