diff --git a/spotifyvis/migrations/0001_initial.py b/spotifyvis/migrations/0001_initial.py deleted file mode 100644 index 167e531..0000000 --- a/spotifyvis/migrations/0001_initial.py +++ /dev/null @@ -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'), - ), - ] diff --git a/spotifyvis/migrations/0002_auto_20180606_0523.py b/spotifyvis/migrations/0002_auto_20180606_0523.py deleted file mode 100644 index 7aaa661..0000000 --- a/spotifyvis/migrations/0002_auto_20180606_0523.py +++ /dev/null @@ -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), - ), - ] diff --git a/spotifyvis/migrations/0003_auto_20180606_0525.py b/spotifyvis/migrations/0003_auto_20180606_0525.py deleted file mode 100644 index b8b50db..0000000 --- a/spotifyvis/migrations/0003_auto_20180606_0525.py +++ /dev/null @@ -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), - ), - ] diff --git a/spotifyvis/models.py b/spotifyvis/models.py index 50be45f..07f73ff 100644 --- a/spotifyvis/models.py +++ b/spotifyvis/models.py @@ -1,19 +1,19 @@ from django.db import models # id's are 22 in length in examples but set to 30 for buffer -id_length=30 - +MAX_ID = 30 # Artist {{{ # + class Artist(models.Model): class Meta: verbose_name = "Artist" verbose_name_plural = "Artists" - artist_id = models.CharField(primary_key=True, max_length=id_length) + artist_id = models.CharField(primary_key=True, max_length=MAX_ID) # unique since only storing one genre per artist right now name = models.CharField(unique=True, max_length=50) - genre = models.CharField(max_length=20) + genre = models.CharField(max_length=30) def __str__(self): return self.name @@ -27,7 +27,7 @@ class User(models.Model): verbose_name = "User" verbose_name_plural = "Users" - user_id = models.CharField(primary_key=True, max_length=id_length) # the user's Spotify ID + user_id = models.CharField(primary_key=True, max_length=MAX_ID) # the user's Spotify ID # username = models.CharField(max_length=30) # User's Spotify user name, if set def __str__(self): @@ -42,15 +42,14 @@ class Track(models.Model): class Meta: verbose_name = "Track" verbose_name_plural = "Tracks" - # unique_together = ('track_id', 'artist',) - track_id = models.CharField(primary_key=True, max_length=id_length) + track_id = models.CharField(primary_key=True, max_length=MAX_ID) # artist = models.ForeignKey(Artist, on_delete=models.CASCADE) artists = models.ManyToManyField(Artist, blank=True) year = models.PositiveSmallIntegerField() popularity = models.PositiveSmallIntegerField() runtime = models.PositiveSmallIntegerField() - name = models.CharField(max_length=75) + name = models.CharField(max_length=150) users = models.ManyToManyField(User, blank=True) def __str__(self): @@ -60,6 +59,7 @@ class Track(models.Model): # AudioFeatures {{{ # + class AudioFeatures(models.Model): class Meta: @@ -79,4 +79,4 @@ class AudioFeatures(models.Model): def __str__(self): return super(AudioFeatures, self).__str__() -# }}} AudioFeatures # +# }}} AudioFeatures # \ No newline at end of file diff --git a/spotifyvis/static/spotifyvis/scripts/test_db.js b/spotifyvis/static/spotifyvis/scripts/test_db.js deleted file mode 100644 index 6830820..0000000 --- a/spotifyvis/static/spotifyvis/scripts/test_db.js +++ /dev/null @@ -1,11 +0,0 @@ -console.log("{{ user_id }}"); -artist_data = JSON.parse('{{ artist_data }}'); -artist_data.forEach(function(d) { - console.log(d.name, d.num_songs); -}); - -d3.json("{% url "get_artist_data" user_id %}", function(error, data) { - data.forEach(function(d) { - console.log(d.name, d.num_songs); - }); -}); diff --git a/spotifyvis/templates/spotifyvis/test_db.html b/spotifyvis/templates/spotifyvis/test_db.html index 3f7a0d0..0c51c81 100644 --- a/spotifyvis/templates/spotifyvis/test_db.html +++ b/spotifyvis/templates/spotifyvis/test_db.html @@ -20,8 +20,13 @@ {% endfor %}
{% filter force_escape %} {% debug %} {% endfilter %}- - {% load static %} - + +