Copied Chris' code to get genre graph working
This commit is contained in:
@@ -211,7 +211,7 @@ def get_artist_data(request, user_secret):
|
|||||||
filter=Q(track__users=user)))
|
filter=Q(track__users=user)))
|
||||||
processed_artist_counts = [{'name': artist.name, 'num_songs': artist.num_songs}
|
processed_artist_counts = [{'name': artist.name, 'num_songs': artist.num_songs}
|
||||||
for artist in artist_counts]
|
for artist in artist_counts]
|
||||||
pprint.pprint(processed_artist_counts)
|
pprint(processed_artist_counts)
|
||||||
return JsonResponse(data=processed_artist_counts, safe=False)
|
return JsonResponse(data=processed_artist_counts, safe=False)
|
||||||
|
|
||||||
# }}} get_artist_data #
|
# }}} get_artist_data #
|
||||||
@@ -257,7 +257,7 @@ def get_genre_data(request, user_secret):
|
|||||||
genre_dict['artists'] = get_artists_in_genre(user, genre_dict['genre'],
|
genre_dict['artists'] = get_artists_in_genre(user, genre_dict['genre'],
|
||||||
genre_dict['num_songs'])
|
genre_dict['num_songs'])
|
||||||
print("*** Genre Breakdown ***")
|
print("*** Genre Breakdown ***")
|
||||||
pprint.pprint(list(genre_counts))
|
pprint(list(genre_counts))
|
||||||
return JsonResponse(data=list(genre_counts), safe=False)
|
return JsonResponse(data=list(genre_counts), safe=False)
|
||||||
|
|
||||||
# }}} get_genre_data #
|
# }}} get_genre_data #
|
||||||
|
|||||||
@@ -46,16 +46,7 @@
|
|||||||
var y = d3.scaleLinear()
|
var y = d3.scaleLinear()
|
||||||
.rangeRound([height, 0]);
|
.rangeRound([height, 0]);
|
||||||
|
|
||||||
// PU: trying to store genreData locally
|
d3.json("{% url "api:get_genre_data" user_secret %}").then(create_genre_graph);
|
||||||
var genreData;
|
|
||||||
d3.json("{% url "api:get_genre_data" user_secret %}",
|
|
||||||
function(data) {
|
|
||||||
genreData = data;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
console.log(genreData);
|
|
||||||
create_genre_graph(genreData);
|
|
||||||
// d3.json("{% url "api:get_genre_data" user_secret %}").then(create_genre_graph);
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -10,8 +10,5 @@ urlpatterns = [
|
|||||||
name='display_genre_graph'),
|
name='display_genre_graph'),
|
||||||
path('audio_features/<str:user_secret>', display_features_graphs,
|
path('audio_features/<str:user_secret>', display_features_graphs,
|
||||||
name='display_audio_features'),
|
name='display_audio_features'),
|
||||||
# path('history/<str:user_secret>', display_history_table,
|
|
||||||
# name='display_history_table'),
|
|
||||||
# path('history/', display_history_table, name='display_history_table'),
|
|
||||||
path('history/', HistoryList.as_view(), name='display_history_table'),
|
path('history/', HistoryList.as_view(), name='display_history_table'),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ class HistoryTable(tables.Table):
|
|||||||
template_name = 'django_tables2/bootstrap.html'
|
template_name = 'django_tables2/bootstrap.html'
|
||||||
|
|
||||||
iso_timestamp = tables.Column(accessor='get_iso_timestamp', orderable=False)
|
iso_timestamp = tables.Column(accessor='get_iso_timestamp', orderable=False)
|
||||||
track_name = tables.Column(accessor='track.name', orderable=False)
|
|
||||||
track_id = tables.Column(accessor='track.id', orderable=False)
|
track_id = tables.Column(accessor='track.id', orderable=False)
|
||||||
|
track_name = tables.Column(accessor='track.name', orderable=False)
|
||||||
artists = tables.Column(accessor='get_artists', orderable=False)
|
artists = tables.Column(accessor='get_artists', orderable=False)
|
||||||
|
|
||||||
def get_secret_context(user_secret):
|
def get_secret_context(user_secret):
|
||||||
|
|||||||
Reference in New Issue
Block a user