Index: music/models.py
===================================================================
--- music/models.py	(revision d7662b5c5695b63b885011417efd780494e2e537)
+++ music/models.py	(revision 0e077ef003e82d99abd40219664904f8ce892305)
@@ -163,16 +163,2 @@
     def __str__(self):
         return f"{self.playlist} - {self.track}"
-
-
-#VIEWS
-
-class tracks_count_per_genre(models.Model):
-    genre = models.CharField(max_length=20, blank=True, null=True)
-    count = models.IntegerField(blank=True, null=True)
-
-    class Meta:
-        db_table = 'tracks_count_per_genre'
-        managed = False
-
-    def __str__(self):
-        return f"{self.genre} - {self.count}"
Index: music/tests.py
===================================================================
--- music/tests.py	(revision d7662b5c5695b63b885011417efd780494e2e537)
+++ music/tests.py	(revision 0e077ef003e82d99abd40219664904f8ce892305)
@@ -8,6 +8,2 @@
 django.setup()
 
-from music.models import Artist
-artists = Artist.objects.raw('SELECT * FROM music_artist')
-for artist in artists:
-    print(artist.name)
Index: music/urls.py
===================================================================
--- music/urls.py	(revision d7662b5c5695b63b885011417efd780494e2e537)
+++ music/urls.py	(revision 0e077ef003e82d99abd40219664904f8ce892305)
@@ -5,5 +5,7 @@
     path('album/', views.album_list, name='album_list'),
     path('artist/', views.artist_list, name='artist_list'),
+    path('artist/avg_track_duration', views.avg_track_duration, name='avg_track_duration'),
     path('track/', views.track_list, name='track_list'),
     path('track/per_genre', views.tracks_count_per_genre, name='track_count_per_genre'),
+    path('customer/rank_list', views.rank_list_most_active_customers, name='rank_list_most_active_customers'),
 ]
Index: music/views.py
===================================================================
--- music/views.py	(revision d7662b5c5695b63b885011417efd780494e2e537)
+++ music/views.py	(revision 0e077ef003e82d99abd40219664904f8ce892305)
@@ -15,5 +15,5 @@
     heading = request.GET.get('model', 'All Albums')
     data = Album.objects.values_list('title', flat=True)
-    return render(request, 'album_list.html', {'data': data, 'heading': heading})
+    return render(request, 'list.html', {'data': data, 'heading': heading})
 
 
@@ -21,7 +21,15 @@
     heading = request.GET.get('model', 'All Tracks')
     data = Track.objects.values_list('name', flat=True)
-    return render(request, 'album_list.html', {'data': data, 'heading': heading})
+    return render(request, 'list.html', {'data': data, 'heading': heading})
 
 
+def artist_list(request):
+    heading = request.GET.get('model', 'All Artists')
+    data = Artist.objects.values_list('name', flat=True)
+    print(data)
+    return render(request, 'list.html', {'data': data, 'heading': heading})
+
+
+# VIEWS
 def tracks_count_per_genre(request):
     with connection.cursor() as cursor:
@@ -35,7 +43,21 @@
 
 
-def artist_list(request):
-    heading = request.GET.get('model', 'All Artists')
-    data = Artist.objects.values_list('name', flat=True)
+def avg_track_duration(request):
+    with connection.cursor() as cursor:
+        cursor.execute("SELECT * FROM avg_track_duration_per_artist;")
+        rows = cursor.fetchall()
+
+    data = [{'artist': row[0], 'avg': row[1]} for row in rows]
     print(data)
-    return render(request, 'album_list.html', {'data': data, 'heading': heading})
+
+    return render(request, 'avg_track_duration.html', {'data': data})
+
+
+def rank_list_most_active_customers(request):
+    with connection.cursor() as cursor:
+        cursor.execute("SELECT * FROM rank_list_most_active_customers_view;")
+        rows = cursor.fetchall()
+
+    data = [{'name': row[0], 'total_orders': row[1], 'total_money_spent': row[2]} for row in rows]
+
+    return render(request, 'rank_list_most_active_customers.html', {'data': data})
Index: music/views/avg_song_duration_per_artist.sql
===================================================================
--- music/views/avg_song_duration_per_artist.sql	(revision 0e077ef003e82d99abd40219664904f8ce892305)
+++ music/views/avg_song_duration_per_artist.sql	(revision 0e077ef003e82d99abd40219664904f8ce892305)
@@ -0,0 +1,7 @@
+CREATE VIEW  avg_track_duration_per_artist AS
+SELECT ar.name as artist_name, concat(ceil(avg(milliseconds) / 1000), 's') as avg_track_duration_in_seconds
+FROM artist ar
+left join album al on ar.artist_id = al.album_id
+left join track tr on al.album_id = tr.album_id
+group by ar.name
+order by ar.name
Index: music/views/rang_list_most_active_customers_view.sql
===================================================================
--- music/views/rang_list_most_active_customers_view.sql	(revision 0e077ef003e82d99abd40219664904f8ce892305)
+++ music/views/rang_list_most_active_customers_view.sql	(revision 0e077ef003e82d99abd40219664904f8ce892305)
@@ -0,0 +1,9 @@
+CREATE  VIEW rank_list_most_active_customers_view AS
+SELECT
+    c.first_name || ' ' || c.last_name as name,
+    COUNT(i.invoice_id) as total_orders,
+    SUM(i.total) as total_money_spent
+from customer c
+LEFT JOIN invoice i on c.customer_id = i.customer_id
+GROUP BY c.first_name, c.last_name
+order by total_money_spent desc
