Commit graph

83 commits

Author SHA1 Message Date
Marc Mogdanz
5ce51c389c
fix(api): use PORT var (#262) 2023-03-19 16:02:49 +01:00
0e2c56bf5f fix(api): properly handle errors in crawler loop 2023-03-17 17:37:14 +01:00
471f46eb8d fix(api): album&track reports only contain one artist
Albums & Tracks can have multiple artists associated with them, but
the previous SQL queries would only return a randomly-chosen one of them.
2023-03-17 17:37:14 +01:00
821b91defe fix(api): importer job was always importing first user
We did read the actual user id from the job data, which caused us
to always import the first user returned by the database.
2023-03-12 21:33:13 +01:00
46b1650066 feat(api): import listens after first sign in
Previously it took a minute until the import was started within the normal
loop. This way, we create an import job right after the user logs
in for the first time.
2023-03-12 02:20:39 +01:00
14478a5418 feat(api): poll listens less often if user is inactive
To save on Spotify API requests we have two different classes of
polling intervals:

- all users are polled at least every 10 minutes, this is a safe interval
  and no listens will be ever missed
- if a user listened to a song within the last 60 minutes, we poll every
  minute to ensure that the UI shows new listens immediately
2023-03-12 02:20:39 +01:00
b9f92bbdfa feat(api): use nest-pg-boss for spotify interactions 2023-03-12 02:20:39 +01:00
ac0f9ff5d3 feat(frontend): manage API tokens in Frontend 2023-02-21 23:07:02 +01:00
8f7eebb806 feat(api): API tokens for authentication
Create and managed simple API tokens for access to the API from external
tools.
2023-02-19 16:19:40 +01:00
0a9956e1ae feat(api): add local repl console
Based on the REPL from NestJS 9
2022-09-27 18:14:49 +02:00
99cc06bbbc chore(deps): upgrade to NestJS 9
chore(deps): update dependency nestjs-otel to v4
chore(deps): update opentelemetry-js monorepo
2022-09-27 18:14:49 +02:00
d6af6f9cba fix(api): missing OpenAPI route tags 2022-07-12 20:34:14 +02:00
2c8e8ef23c fix(api): remove unwanted debug log messages 2022-07-07 17:18:54 +02:00
41dfae3c50 feat(api): metrics for Spotify API http requests
This will help evaluate how much we are being rate limited, and on what
routes it happens most.
2022-06-29 21:30:09 +02:00
85c31705ef refactor(api): replace deprecated toPromise calls
Details: https://rxjs.dev/deprecations/to-promise
2022-06-29 21:30:09 +02:00
be38c383ef fix(api): some listens pages are not full
Without this option, some pages on the listens list are returning less than
requested items.
2022-06-25 16:50:48 +02:00
renovate[bot]
ef84800ce8 chore(deps): update typeorm 2022-06-25 16:26:58 +02:00
8d9e99039c fix(api): send trace context to sentry
This helps associating errors in sentry with the full trace context
2022-06-23 18:26:42 +02:00
fd3fc6b159 fix(api): missing await 2022-06-19 20:35:44 +02:00
99a4593774 fix(api): improve performance of all time listens report
The current algorithm is CPU intensive and blocks the event loop for
multiple seconds in my deployment. This is not acceptable, as other
requests can not be answered during that time.

I do not have time to fully fix the issue here, but I did implement an
optimization for ALL_TIME reports:

Before, the all time report was generated for every timeFrame since 1970,
which iterated over the listens many hundred times. We can instead only start
the interval at the day of the first listen, and therefore skip 50+ years
of calculations.
2022-06-19 20:35:30 +02:00
6b1640b753 feat(observability): Replace Prometheus package with OpenTelemetry 2022-06-18 17:48:16 +02:00
a2ea89ff96 fix(api): broken tests after linting fix 2022-06-11 22:55:13 +02:00
84cf3391f1 chore(deps): update typescript-eslint monorepo to v5 2022-06-11 19:21:00 +02:00
ee5bd41a37 feat(api): configurable max pool connections
This should help with failing health checks while the crawler is running.

Quick math: 10 users, 30 songs each, each song requires at least 3
queries => 900 db queries every minute.

With the default of 10 pool connections, this blocks all available db
bandwidth for some time and causes slow UI and failing healthchecks.
2022-06-11 19:21:00 +02:00
7de5e14d4e fix(health): remove faulty health check to spotify-auth
The endpoint returns a 503 OFTEN (~1x per hour), which causes unnecessary
service restarts and issues in sentry.
2022-06-11 19:21:00 +02:00
f06b93efbe fix(health): use not-deprecated sentry context
The setExtra function is deprecated in favor of setContext. Also update
sentry-related packages.
2022-06-11 19:21:00 +02:00
dbf4374aeb fix(health): send healthcheck result to sentry to improve debugging 2022-06-11 14:02:48 +02:00
a0ffe108e1 feat(api): update existing artists in MusicLibrary 2021-11-21 15:53:49 +01:00
a0c28e2324 feat: top genres report 2021-11-21 15:53:49 +01:00
Renovate Bot
19d7700696 chore(deps): update dependency passport-spotify to v2 2021-08-15 16:14:52 +02:00
Renovate Bot
a3c6da2749 chore(deps): update nest monorepo 2021-08-12 17:08:23 +02:00
e476243b85 test: create initial unit tests 2021-07-18 21:57:38 +02:00
3695fb7182 refactor(api): replace deprecated DNSHealthCheck 2021-06-22 21:06:35 +02:00
73bba4ef68 refactor(api): remove deprecated function and rename exception 2021-06-22 20:34:55 +02:00
3c6f3289f1 feat(server): save genres for artists and albums
This can later be used for reports
2021-05-25 19:23:42 +02:00
9b96d0fab4 chore(lint): switch to eslint 2021-05-25 18:12:42 +02:00
f56548e432 chore: run prettier format 2021-05-25 16:02:00 +02:00
51fd78f6d9 feat: add top tracks report 2021-05-22 15:10:05 +02:00
0c2188c4d4 fix(api): continue crawling when access token refresh fails for one user 2021-05-20 19:19:24 +02:00
879c6a62e2 feat: add optional basic auth for metrics endpoint 2020-12-06 03:03:33 +01:00
66fd6ce1b4 feat(api): custom spotify crawler interval 2020-11-28 18:28:38 +01:00
97f5ef70ac refactor(api): improve function naming in spotify source 2020-11-28 17:56:49 +01:00
5ca3437b59 fix(api): missed listens from spotify
Listory could miss some listens when the Spotify Api misbehaves.

Sometimes the listens added to the last-recently-played endpoint
are showing up are out-of-order.

Because of our optimization to only retrieve listens newer than
the lastRefreshTime we would skip retrieving those out-of-order listens.

By always retrieving the maximum 50 listens we can be reasonably
sure that we got all the listens.

We also had to improve the handling of duplicate listens, as we now
have a lot of them, curtesy of removing the lastRefreshTime
optimization.
2020-11-28 17:55:19 +01:00
e2056b4734 feat(api): add prometheus metrics
Currently we support metrics for the Node.js runtime and HTTP endpoints.
2020-11-21 19:55:53 +01:00
9869f0a061 refactor(api): improve logging around spotify crawling loop 2020-11-21 17:43:04 +01:00
fcc2f7d1b6 fix(api): db error on duplicate music library import
When the spotify crawler loop would import an artist multiple
times in parallel the first would succeed but the following queries
would throw with following exception:

    QueryFailedError: duplicate key value violates unique constraint "IDX_ARTIST_SPOTIFY_ID"

This error also could happen for the album or track.
2020-11-21 17:00:33 +01:00
49b31e8e62 fix(api): exception after refreshing spotify access token 2020-11-18 21:13:16 +01:00
56db4cd2e1 feat(api): setup optional sentry error reporting 2020-11-17 22:26:08 +01:00
9896ea31ff feat: introduce new report "Top Albums" 2020-11-15 02:43:23 +01:00
09858076bf refactor(api): optimize imports 2020-11-15 02:37:01 +01:00