From d8e4b0f6ddd553367abe9ecfd739def4572d92f5 Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Fri, 23 Aug 2019 04:08:15 -0400 Subject: [PATCH] Improve installation instructions --- README.md | 72 +++++++++++++++++---------------- scripts/queries/most-played.sql | 9 +++-- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index d45e191..f7430bf 100644 --- a/README.md +++ b/README.md @@ -8,47 +8,51 @@ These instructions will get you a copy of the project up and running on your loc ### Prerequisites -Before starting the setup, make sure Python 3 and PostgreSQL is installed on your system. +- Python 3 + - `pip` +- PostgreSQL + +#### On Debian/Ubunu +``` shell +sudo apt-get install python3-pip +sudo apt-get install postgresql +sudo apt-get install python-psycopg2 +sudo apt-get install libpq-dev +pip install --user virtualenv +``` ### Installing -1. Use the pip tool to install `virtualenv`. See this [guide](http://docs.python-guide.org/en/latest/dev/virtualenvs/) for further details. +1. Create a virtual environment. + ``` shell + virtualenv /path/to/new/virtual/environment + ``` -``` -pip install --user pipenv -``` -2. Create a virtual environment. - -``` -python3 -m venv /path/to/new/virtual/environment -``` -3. `cd` into the directory you just created a virtual environment in, +1. `cd` into the directory you just created a virtual environment in, and clone the GitHub repo: - -``` -cd /path/to/new/virtual/environment -git clone https://github.com/Kevin-Mok/spotify-lib-vis -``` -4. Activate the virtual environment from the command line. - -``` -# activate.fish if you're using fish shell -source bin/activate -``` -5. `cd` into the repository root directory and install all -dependencies using `pip`. - -``` -cd spotify-lib-vis -pip install -r requirements.txt -``` -6. Run `reset_db.sh` to create the database and start the server. - -``` -./scripts/reset_db.sh -``` + ``` shell + cd /path/to/new/virtual/environment + git clone https://github.com/Kevin-Mok/spotify-lib-vis + ``` + +1. Activate the virtual environment from the command line. + ``` shell + # activate.fish if you're using fish shell + source bin/activate + ``` + +1. `cd` into the repository root directory and install all dependencies using `pip`. + ``` shell + cd spotify-lib-vis + pip3 install -r requirements.txt + ``` + +1. Run `reset_db.sh` to create the database and start the server. + ``` shell + ./scripts/reset_db.sh + ``` diff --git a/scripts/queries/most-played.sql b/scripts/queries/most-played.sql index 828a1eb..cd43756 100644 --- a/scripts/queries/most-played.sql +++ b/scripts/queries/most-played.sql @@ -1,5 +1,6 @@ -- select t.name as track, a.name as artist -select substring(t.name for 50) as track, a.name as artist, count(t.id) +select distinct on (1) +timestamp, substring(t.name for 50) as track, a.name as artist from api_history as h join api_track as t on h.track_id = t.id @@ -7,6 +8,6 @@ join api_track_artists ta on ta.track_id = t.id join api_artist a on a.id = ta.artist_id -group by t.id, a.id -order by count(t.id) desc; --- limit 10; +order by timestamp desc +-- ; +limit 20;