openpodcast / api

OpenPodcast API server
https://openpodcast.dev
8 stars 2 forks source link

Status API #46

Closed mre closed 1 year ago

mre commented 1 year ago

This is a new endpoint, which returns the timestamps of the latest endpoint calls per account, e.g.

{
    "account_id": 1,
    "latestUpdates": [
        "aggregate": "2021-01-01 00:00:00"
        "detailedStreams": "2021-01-01 00:00:00"
    ]
}

It is helpful for building an API status page in the future.

woolfg commented 1 year ago

currently I need a token in the header to see the status, right? this might be a bit tricky for a simple check by the user? what about just showing the podcast_ids an the last action of it?

mre commented 1 year ago

what about just showing the podcast_ids an the last action of it?

We would leak all podcast ids and the API could be a public endpoint, so I'm not sure if we can/should do this. 🤔

mre commented 1 year ago

Most likely this endpoint will be used by a status page for a single podcast, so providing the token shouldn't be a big deal.

mre commented 1 year ago

We agreed that we will use MySQL's event scheduler to remove events older than 7 days.

mre commented 1 year ago

Unfortunately the event keyword is not supported by PlanetScale. See https://planetscale.com/docs/reference/mysql-compatibility and https://github.com/planetscale/discussion/discussions/265.

woolfg commented 1 year ago

can be testen locally using the stack repo?

woolfg commented 1 year ago

with the new changed in stack it should be possible to test it there. according to https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_event_scheduler it is ON by default anyways.

mre commented 1 year ago

Example response:

{
  "1": {
    "latestUpdates": {
      "metadata": "2022-12-23T15:03:47.000Z",
      "detailedStreams": "2022-12-23T15:05:14.000Z",
      "listeners": "2022-12-23T15:05:17.000Z",
      "aggregate": "2022-12-23T15:05:12.000Z",
      "followers": "2022-12-23T15:04:00.000Z",
      "episodes": "2022-12-23T15:04:03.000Z",
      "performance": "2022-12-23T15:05:19.000Z"
    }
  },
  "2": {
    "latestUpdates": {
      "listeners": "2023-01-30T11:30:38.000Z"
    }
  }
}