Coder Social home page Coder Social logo

patricianapp / patrician-api Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 1.31 MB

The GraphQL API for interacting with the Patrician database

Home Page: https://api.patrician.app

License: GNU General Public License v3.0

TypeScript 93.73% JavaScript 6.27%
postgresql typeorm typegraphql public-api graphql music-collection musicbrainz spotify lastfm rateyourmusic discogs warthog

patrician-api's Introduction

docker-compose exec -u postgres postgres psql \l \c \dt

patrician-api's People

Contributors

fossforlife avatar

Stargazers

 avatar

Watchers

 avatar

patrician-api's Issues

Dockerize

Acceptance Criteria

  • Dockerfile is created for our API using node:13 as the base image
  • API is added to docker-compose file and routed to use Docker Postgres
  • Maybe: eliminate external routing for Postgres container? (So that it's only used by the app and not exposed outside Docker)

Pagination

Right now the query resolvers return all items in the db. We want paginated results, ideally using Relay specification.

Warthog plans to have a feature for this so we might wait until that is finalized.

ESLint/Prettier

Implement ESLint, Prettier, and pre-commit hooks for both.

Adding Items To Collection

Users should be able to:

  • add items manually by artist and title
  • add items manually by MBID
  • add additional metadata in the creation payload (release date, etc)

The server should automatically:

  • fetch metadata from MusicBrainz, either using MBID or by searching artist/title
  • merge items that are the same
  • follow every step in the chart below upon adding an item

This import function below is what will handle user imports, Spotify/Last.fm/RYM imports, and any other method of adding items.

Import Page (A): Last.fm/Spotify

The first iteration of our import page will allow manual imports from Last.fm and Spotify, since these two are the most important.

  • Continuous imports will probably come at a later date.
  • Adding the items to our database will be handled using the existing API function

To be created:

  • UI page that authenticates the user, kicks off the Lambda functions below, and displays the collection queue
  • Last.fm import Lambda function that fetches scrobble history and adds items to collection queue
  • Spotify import Lambda function that fetches saved albums and adds them to collection queue

To be updated:

  • Collection database needs to have "queue" functionality and store all of the fields that we want to display during this process (e.g. import source, Last.fm plays, etc)

Authenticated CRUD for user collections

Dependencies

  • login mutation (#6)

Acceptance Criteria

  • Get the basic authChecker working (from Warthog example)
  • CRUD queries/mutations for signed-in user ("me" resolver)
  • Parse JWT inside Server context function

Log in

Acceptance Criteria

  • New login mutation has been created
  • Returns some sort of auth token that can be used for future requests

Import by ID

We have a searchByIdentifiers() function in "item.service.ts" that searches for a single item by mbid, artist and title, which is used to check if an item already exists in the database before adding to a user's collection.

We simply need to add an "id" parameter which will also search the item's ID, and then update the addItems() function to add the id into the searchInput if it exists.

Reviewing Items

Acceptance Criteria

  • Add review to item
    • Includes rating, title
  • See review on item page
  • Review history: New reviews get added on top of old ones
    • Can only be viewed by the logged in user
  • Can undo changes based on review history
  • Limit how much history is saved (e.g. 50 reviews)
  • Can delete review (this is permanent and deletes all history)
  • Draft review (sets visibility to false)
  • Integrate text editor plugin (Slate, Draft, etc)
    • Should save to database in Markdown or HTML format

Heroku Deployment

Automatically deploy to Heroku on all non-canary releases (x.x.x)

Searching through collections

UI Features

  • A new search query is sent with each letter typed, and the collection view auto-updates
    • (as long as the query is valid)
  • You can filter items using the query syntax
  • Filters are automatically syntax-highlighted
  • There will also be a "Filters" expansion panel to set these through the UI
  • "Sort by" dropdown: Artist A-Z, Plays, Rating
  • Advanced: Each search query should not be grabbing full item info, just the IDs (since some item info will already be in browser session, and this will allow for smoother performance)

Query syntax (WIP)

Example queries

Searching for a specific album:

my bloody valentine loveless
artist:'my bloody valentine' loveless
artistId:'my-bloody-valentine-ir1' loveless
id:'my-bloody-valentine-loveless'

Browsing:

artist:'mastodon' released-before:2009 genre:'sludge metal'
list:'nostalgic-albums' tag:heavy rating-gt:8 has:review
added-in:2020 plays-gt:50

Comparing collections:

in:user/afantano 
in:user/afantano/loved-list     # This is a view within a user's collection

Seeing your play stats (note: you can sort by plays in the dropdown menu):

plays-gt:400
plays-after:2020-01-01 plays-before:2021-01-01   # Only count plays in 2020
plays-in:2020    # Same as above

Identifiers

(These are filters that can only return one or zero items, so all other filters will be ignored)

id:
mbid:
rymId:
spotifyId:

Basic

[date-qualifier] = before/after/in: (YYY0s, YYYY, YYYY-MM, YYYY-MM-DD), on: (YYYY-MM-DD)

"gt" and "lt" will probably equate to "greater/less than or equal to" instead of "greater/less than", because this is probably the more common use case

added-[date-qualifier]:
artist:
artistId:
first-listened-[date-qualifier]:
folder:
genre:
has:artist-review
has:favorite-tracks
has:likes-dislikes
has:review
in:wishlist
last-listened-[date-qualifier]:
list:
plays-gt:
plays-lt:
rating:
rating-gt:
rating-lt:
released-[date-qualifier]:
tag:
updated-[date-qualifier]:

Advanced

[custom-field]: Any custom field that the user has created, along with any valid value.
in: (user/[user] or user/[user]/[view]) Whether the item also exists in another user's collection
get:artists/items/tracks Which type of result should be returned (default: items)
plays-[before/after]: This can be used to create a date range for plays, similar to Last.fm's functionality. (This will not be possible until we are storing play/scrobble data which is way in the future)
view:[view] Whether the item exists in a view (which is basically a saved filter query)

CollectionItem primary key should be its relations (item and user)

Right now its primary key (as with all data models that implement Warthog's BaseModel) is an autogenerated ID. We want the primary key to instead be the item and user that the CollectionItem is connected to, because 1) the combination of these is unique, and 2) we want to be able to easily and quickly fetch these CollectionItems by their item and user IDs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.