Browse Source
Merge pull request #30 from Kevin-Mok/in-progress
Merge pull request #30 from Kevin-Mok/in-progress
- pass data from database to D3 JS - deleted migration history - modified `views.py, utils.py` to be more directed toward using database vs. `library_stats`master
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 145 additions and 224 deletions
-
79spotifyvis/migrations/0001_initial.py
-
53spotifyvis/migrations/0002_auto_20180606_0523.py
-
23spotifyvis/migrations/0003_auto_20180606_0525.py
-
16spotifyvis/models.py
-
1spotifyvis/templates/spotifyvis/index.html
-
32spotifyvis/templates/spotifyvis/test_db.html
-
1spotifyvis/templates/spotifyvis/user_data.html
-
14spotifyvis/urls.py
-
91spotifyvis/utils.py
-
31spotifyvis/views.py
@ -1,79 +0,0 @@ |
|||||
# Generated by Django 2.0.5 on 2018-06-06 07:26 |
|
||||
|
|
||||
from django.db import migrations, models |
|
||||
import django.db.models.deletion |
|
||||
|
|
||||
|
|
||||
class Migration(migrations.Migration): |
|
||||
|
|
||||
initial = True |
|
||||
|
|
||||
dependencies = [ |
|
||||
] |
|
||||
|
|
||||
operations = [ |
|
||||
migrations.CreateModel( |
|
||||
name='Artist', |
|
||||
fields=[ |
|
||||
('artist_id', models.CharField(max_length=30, primary_key=True, serialize=False)), |
|
||||
('name', models.CharField(max_length=50, unique=True)), |
|
||||
('genre', models.CharField(max_length=20)), |
|
||||
], |
|
||||
options={ |
|
||||
'verbose_name_plural': 'Artists', |
|
||||
'verbose_name': 'Artist', |
|
||||
}, |
|
||||
), |
|
||||
migrations.CreateModel( |
|
||||
name='Track', |
|
||||
fields=[ |
|
||||
('track_id', models.CharField(max_length=30, primary_key=True, serialize=False)), |
|
||||
('year', models.PositiveSmallIntegerField()), |
|
||||
('popularity', models.PositiveSmallIntegerField()), |
|
||||
('runtime', models.PositiveSmallIntegerField()), |
|
||||
('name', models.CharField(max_length=75)), |
|
||||
], |
|
||||
options={ |
|
||||
'verbose_name_plural': 'Tracks', |
|
||||
'verbose_name': 'Track', |
|
||||
}, |
|
||||
), |
|
||||
migrations.CreateModel( |
|
||||
name='User', |
|
||||
fields=[ |
|
||||
('user_id', models.CharField(max_length=30, primary_key=True, serialize=False)), |
|
||||
], |
|
||||
options={ |
|
||||
'verbose_name_plural': 'Users', |
|
||||
'verbose_name': 'User', |
|
||||
}, |
|
||||
), |
|
||||
migrations.CreateModel( |
|
||||
name='AudioFeatures', |
|
||||
fields=[ |
|
||||
('track', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='spotifyvis.Track')), |
|
||||
('danceability', models.DecimalField(decimal_places=2, max_digits=2)), |
|
||||
('energy', models.DecimalField(decimal_places=2, max_digits=2)), |
|
||||
('loudness', models.DecimalField(decimal_places=2, max_digits=2)), |
|
||||
('speechiness', models.DecimalField(decimal_places=2, max_digits=2)), |
|
||||
('acousticness', models.DecimalField(decimal_places=2, max_digits=2)), |
|
||||
('instrumentalness', models.DecimalField(decimal_places=2, max_digits=2)), |
|
||||
('valence', models.DecimalField(decimal_places=2, max_digits=2)), |
|
||||
('tempo', models.DecimalField(decimal_places=2, max_digits=2)), |
|
||||
], |
|
||||
options={ |
|
||||
'verbose_name_plural': 'AudioFeatures', |
|
||||
'verbose_name': 'AudioFeatures', |
|
||||
}, |
|
||||
), |
|
||||
migrations.AddField( |
|
||||
model_name='track', |
|
||||
name='artists', |
|
||||
field=models.ManyToManyField(blank=True, to='spotifyvis.Artist'), |
|
||||
), |
|
||||
migrations.AddField( |
|
||||
model_name='track', |
|
||||
name='users', |
|
||||
field=models.ManyToManyField(blank=True, to='spotifyvis.User'), |
|
||||
), |
|
||||
] |
|
@ -1,53 +0,0 @@ |
|||||
# Generated by Django 2.0.5 on 2018-06-06 09:23 |
|
||||
|
|
||||
from django.db import migrations, models |
|
||||
|
|
||||
|
|
||||
class Migration(migrations.Migration): |
|
||||
|
|
||||
dependencies = [ |
|
||||
('spotifyvis', '0001_initial'), |
|
||||
] |
|
||||
|
|
||||
operations = [ |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='acousticness', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=3), |
|
||||
), |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='danceability', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=3), |
|
||||
), |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='energy', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=3), |
|
||||
), |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='instrumentalness', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=3), |
|
||||
), |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='loudness', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=3), |
|
||||
), |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='speechiness', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=3), |
|
||||
), |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='tempo', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=3), |
|
||||
), |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='valence', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=3), |
|
||||
), |
|
||||
] |
|
@ -1,23 +0,0 @@ |
|||||
# Generated by Django 2.0.5 on 2018-06-06 09:25 |
|
||||
|
|
||||
from django.db import migrations, models |
|
||||
|
|
||||
|
|
||||
class Migration(migrations.Migration): |
|
||||
|
|
||||
dependencies = [ |
|
||||
('spotifyvis', '0002_auto_20180606_0523'), |
|
||||
] |
|
||||
|
|
||||
operations = [ |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='loudness', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=6), |
|
||||
), |
|
||||
migrations.AlterField( |
|
||||
model_name='audiofeatures', |
|
||||
name='tempo', |
|
||||
field=models.DecimalField(decimal_places=3, max_digits=6), |
|
||||
), |
|
||||
] |
|
@ -0,0 +1,32 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> |
||||
|
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> |
||||
|
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> |
||||
|
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
|
<title>Test DB Page</title> |
||||
|
<meta name="description" content=""> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<!--[if lt IE 7]> |
||||
|
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p> |
||||
|
<![endif]--> |
||||
|
<ul> |
||||
|
{% for artist in artist_data %} |
||||
|
<li>{{ artist.name }} - {{ artist.num_songs }}</li> |
||||
|
{% endfor %} |
||||
|
</ul> |
||||
|
<pre> {% filter force_escape %} {% debug %} {% endfilter %} </pre> |
||||
|
<script src="https://d3js.org/d3.v5.min.js"></script> |
||||
|
<script> |
||||
|
d3.json("{% url "get_artist_data" user_id %}").then(function(data) { |
||||
|
data.forEach(function(d) { |
||||
|
console.log(d.name, d.num_songs); |
||||
|
}); |
||||
|
}); |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
@ -1,9 +1,13 @@ |
|||||
from django.urls import path, include |
from django.urls import path, include |
||||
from . import views |
|
||||
|
from django.conf.urls import url |
||||
|
|
||||
|
from .views import * |
||||
|
|
||||
urlpatterns = [ |
urlpatterns = [ |
||||
path('', views.index, name='index'), |
|
||||
path('login', views.login, name='login'), |
|
||||
path('callback', views.callback, name='callback'), |
|
||||
path('user_data', views.user_data, name='user_data'), |
|
||||
|
path('', index, name='index'), |
||||
|
path('login', login, name='login'), |
||||
|
path('callback', callback, name='callback'), |
||||
|
path('user_data', user_data, name='user_data'), |
||||
|
path('test_db', test_db, name='test_db'), |
||||
|
path('user_artists/<str:user_id>', get_artist_data, name='get_artist_data'), |
||||
] |
] |
Write
Preview
Loading…
Cancel
Save
Reference in new issue