Index: music/admin.py
===================================================================
--- music/admin.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ music/admin.py	(revision d7662b5c5695b63b885011417efd780494e2e537)
@@ -16,3 +16,2 @@
 admin.site.register(PlaylistTrack, PlaylistTrackAdmin)
 admin.site.register(Track)
-admin.site.register(DeletedCustomerLog)
Index: music/middleware.py
===================================================================
--- music/middleware.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,13 +1,0 @@
-from django.shortcuts import redirect
-from django.http import Http404
-
-class Redirect404ToHomeMiddleware:
-    def __init__(self, get_response):
-        self.get_response = get_response
-
-    def __call__(self, request):
-        try:
-            response = self.get_response(request)
-            return response
-        except Http404:
-            return redirect('homepage')
Index: music/migrations/0004_deletedcustomerlog_delete_tracks_count_per_genre_and_more.py
===================================================================
--- music/migrations/0004_deletedcustomerlog_delete_tracks_count_per_genre_and_more.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,39 +1,0 @@
-# Generated by Django 5.1.3 on 2025-05-07 07:43
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ("music", "0003_tracks_count_per_genre"),
-    ]
-
-    operations = [
-        migrations.CreateModel(
-            name="DeletedCustomerLog",
-            fields=[
-                ("log_id", models.AutoField(primary_key=True, serialize=False)),
-                ("first_name", models.CharField(max_length=40)),
-                ("last_name", models.CharField(max_length=20)),
-                ("deleted_at", models.DateTimeField()),
-                ("total_spent", models.DecimalField(decimal_places=2, max_digits=10)),
-                ("invoice_count", models.IntegerField()),
-            ],
-            options={
-                "db_table": "deleted_customer_log",
-                "managed": False,
-            },
-        ),
-        migrations.DeleteModel(
-            name="tracks_count_per_genre",
-        ),
-        migrations.AlterModelOptions(
-            name="invoice",
-            options={"managed": False},
-        ),
-        migrations.AlterModelOptions(
-            name="invoiceline",
-            options={"managed": False},
-        ),
-    ]
Index: music/migrations/0005_alter_deletedcustomerlog_options_and_more.py
===================================================================
--- music/migrations/0005_alter_deletedcustomerlog_options_and_more.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,29 +1,0 @@
-# Generated by Django 5.1.3 on 2025-05-07 09:03
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ("music", "0004_deletedcustomerlog_delete_tracks_count_per_genre_and_more"),
-    ]
-
-    operations = [
-        migrations.AlterModelOptions(
-            name="deletedcustomerlog",
-            options={},
-        ),
-        migrations.AlterModelOptions(
-            name="invoice",
-            options={},
-        ),
-        migrations.AlterModelOptions(
-            name="invoiceline",
-            options={},
-        ),
-        migrations.AlterModelOptions(
-            name="playlisttrack",
-            options={},
-        ),
-    ]
Index: music/migrations/0006_alter_deletedcustomerlog_options_and_more.py
===================================================================
--- music/migrations/0006_alter_deletedcustomerlog_options_and_more.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,49 +1,0 @@
-# Generated by Django 5.1.3 on 2025-05-07 11:22
-
-import django.db.models.deletion
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ("music", "0005_alter_deletedcustomerlog_options_and_more"),
-    ]
-
-    operations = [
-        migrations.AlterModelOptions(
-            name="deletedcustomerlog",
-            options={"managed": False},
-        ),
-        migrations.AlterModelOptions(
-            name="invoice",
-            options={"managed": False},
-        ),
-        migrations.AlterModelOptions(
-            name="invoiceline",
-            options={"managed": False},
-        ),
-        migrations.AlterModelOptions(
-            name="playlisttrack",
-            options={"managed": False},
-        ),
-        migrations.CreateModel(
-            name="Price",
-            fields=[
-                ("price_id", models.AutoField(primary_key=True, serialize=False)),
-                ("value", models.DecimalField(decimal_places=2, max_digits=10)),
-                ("date", models.DateTimeField()),
-                (
-                    "track_id",
-                    models.ForeignKey(
-                        db_column="track_id",
-                        on_delete=django.db.models.deletion.DO_NOTHING,
-                        to="music.track",
-                    ),
-                ),
-            ],
-            options={
-                "db_table": "price",
-            },
-        ),
-    ]
Index: music/migrations/0007_alter_price_options.py
===================================================================
--- music/migrations/0007_alter_price_options.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,17 +1,0 @@
-# Generated by Django 5.1.3 on 2025-05-07 11:22
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ("music", "0006_alter_deletedcustomerlog_options_and_more"),
-    ]
-
-    operations = [
-        migrations.AlterModelOptions(
-            name="price",
-            options={"managed": False},
-        ),
-    ]
Index: music/models.py
===================================================================
--- music/models.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ music/models.py	(revision d7662b5c5695b63b885011417efd780494e2e537)
@@ -113,5 +113,5 @@
 class Invoice(models.Model):
     invoice_id = models.AutoField(primary_key=True)
-    customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, db_column='customer_id', null=True)
+    customer = models.ForeignKey(Customer, on_delete=models.CASCADE, db_column='customer_id')
     invoice_date = models.DateTimeField()
     billing_address = models.CharField(max_length=70, blank=True, null=True)
@@ -127,5 +127,4 @@
     class Meta:
         db_table = 'invoice'
-        managed = False
 
 
@@ -139,5 +138,4 @@
     class Meta:
         db_table = 'invoice_line'
-        managed = False
 
 
@@ -167,28 +165,14 @@
 
 
-class DeletedCustomerLog(models.Model):
-    log_id = models.AutoField(primary_key=True)
-    first_name = models.CharField(max_length=40)
-    last_name = models.CharField(max_length=20)
-    deleted_at = models.DateTimeField()
-    total_spent = models.DecimalField(max_digits=10, decimal_places=2)
-    invoice_count = models.IntegerField()
+#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 = 'deleted_customer_log'
+        db_table = 'tracks_count_per_genre'
         managed = False
 
     def __str__(self):
-        return f"{self.first_name} {self.last_name} - Deleted on {self.deleted_at} - Total Spent: ${self.total_spent} from {self.invoice_count} invoices"
-
-class Price(models.Model):
-    price_id = models.AutoField(primary_key=True)
-    value = models.DecimalField(max_digits=10, decimal_places=2)
-    date = models.DateTimeField()
-    track_id = models.ForeignKey(Track, on_delete=models.DO_NOTHING, db_column='track_id')
-
-    class Meta:
-        managed = False
-        db_table = 'price'
-
-    def __str__(self):
-        return f"{self.track_id} - {self.value} - {self.date}"
+        return f"{self.genre} - {self.count}"
Index: music/tests.py
===================================================================
--- music/tests.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ music/tests.py	(revision d7662b5c5695b63b885011417efd780494e2e537)
@@ -8,2 +8,6 @@
 django.setup()
 
+from music.models import Artist
+artists = Artist.objects.raw('SELECT * FROM music_artist')
+for artist in artists:
+    print(artist.name)
Index: music/triggers/customer_deletion.sql
===================================================================
--- music/triggers/customer_deletion.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,31 +1,0 @@
-DROP TRIGGER IF EXISTS trg_customer_deletion ON customer;
-DROP FUNCTION IF EXISTS customer_deletion();
-
-CREATE OR REPLACE FUNCTION customer_deletion()
-RETURNS TRIGGER AS $$
-DECLARE
-    total_spent NUMERIC(10, 2);
-    invoice_count INTEGER;
-BEGIN
-    SELECT COALESCE(SUM(total), 0), COUNT(*)
-    INTO total_spent, invoice_count
-    FROM invoice
-    WHERE customer_id = OLD.customer_id;
-
-    INSERT INTO deleted_customer_log (
-        first_name, last_name, deleted_at, total_spent, invoice_count
-    )
-    VALUES (
-        OLD.first_name, OLD.last_name, NOW(), total_spent, invoice_count
-    );
-
-    RETURN OLD;
-END;
-$$ LANGUAGE plpgsql;
-
-DROP TRIGGER IF EXISTS trg_customer_deletion ON customer;
-
-CREATE TRIGGER trg_customer_deletion
-BEFORE DELETE ON customer
-FOR EACH ROW
-EXECUTE FUNCTION customer_deletion();
Index: music/triggers/insert_price_on_track_insert.sql
===================================================================
--- music/triggers/insert_price_on_track_insert.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,14 +1,0 @@
-CREATE OR REPLACE FUNCTION insert_price_on_track_insert()
-RETURNS TRIGGER AS $$
-BEGIN
-  INSERT INTO price (value, date, track_id)
-  VALUES (NEW.unit_price, NOW(), NEW.track_id);
-
-  RETURN NEW;
-END;
-$$ LANGUAGE plpgsql;
-
-CREATE TRIGGER insert_price_on_track_insert
-AFTER INSERT ON track
-FOR EACH ROW
-EXECUTE FUNCTION insert_price_on_track_insert();
Index: music/triggers/insert_price_on_track_update.sql
===================================================================
--- music/triggers/insert_price_on_track_update.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,16 +1,0 @@
-CREATE OR REPLACE FUNCTION insert_price_on_track_update()
-RETURNS TRIGGER AS
-$$
-BEGIN
-    INSERT INTO price (value, date, track_id)
-    VALUES (NEW.unit_price, NOW(), NEW.track_id);
-
-    RETURN NEW;
-END;
-$$ LANGUAGE plpgsql;
-
-CREATE TRIGGER insert_price_on_track_update
-    AFTER UPDATE
-    ON track
-    FOR EACH ROW
-EXECUTE FUNCTION insert_price_on_track_update();
Index: music/triggers/media_type_deletion.sql
===================================================================
--- music/triggers/media_type_deletion.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,20 +1,0 @@
-CREATE OR REPLACE FUNCTION media_type_deletion()
-RETURNS TRIGGER AS $$
-BEGIN
-    IF OLD.media_type_id = 1 THEN
-        RAISE EXCEPTION 'Cannot delete default media type (MPEG audio file with id = 1).';
-    END IF;
-
-    UPDATE track
-    SET media_type_id = 1
-    WHERE media_type_id = OLD.media_type_id;
-
-    RETURN OLD;
-END;
-$$ LANGUAGE plpgsql;
-
-
-CREATE TRIGGER trg_media_type_deletion
-BEFORE DELETE ON media_type
-FOR EACH ROW
-EXECUTE FUNCTION media_type_deletion();
Index: music/triggers/normalize_and_validate_customer_email.sql
===================================================================
--- music/triggers/normalize_and_validate_customer_email.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,17 +1,0 @@
-CREATE OR REPLACE FUNCTION normalize_and_validate_customer_email()
-RETURNS TRIGGER AS $$
-BEGIN
-    NEW.email := LOWER(NEW.email);
-
-    IF NEW.email !~* '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$' THEN
-        RAISE EXCEPTION 'Invalid email format: %', NEW.email;
-    END IF;
-
-    RETURN NEW;
-END;
-$$ LANGUAGE plpgsql;
-
-CREATE TRIGGER trg_normalize_validate_email
-BEFORE INSERT ON customer
-FOR EACH ROW
-EXECUTE FUNCTION normalize_and_validate_customer_email();
Index: music/triggers/prevent_artist_deletion.sql
===================================================================
--- music/triggers/prevent_artist_deletion.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,17 +1,0 @@
-CREATE OR REPLACE FUNCTION prevent_artist_deletion()
-RETURNS TRIGGER AS $$
-BEGIN
-    IF EXISTS (
-        SELECT 1 FROM album WHERE artist_id = OLD.artist_id
-    ) THEN
-        RAISE EXCEPTION 'Cannot delete artist with albums.';
-    END IF;
-
-    RETURN OLD;
-END;
-$$ LANGUAGE plpgsql;
-
-CREATE TRIGGER trg_prevent_artist_deletion
-BEFORE DELETE ON artist
-FOR EACH ROW
-EXECUTE FUNCTION prevent_artist_deletion();
Index: music/triggers/prevent_genre_deletion.sql
===================================================================
--- music/triggers/prevent_genre_deletion.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,17 +1,0 @@
-CREATE OR REPLACE FUNCTION prevent_genre_deletion()
-RETURNS TRIGGER AS $$
-BEGIN
-    IF EXISTS (
-        SELECT 1 FROM track WHERE genre_id = OLD.genre_id
-    ) THEN
-        RAISE EXCEPTION 'Cannot delete genre with a track of it.';
-    END IF;
-
-    RETURN OLD;
-END;
-$$ LANGUAGE plpgsql;
-
-CREATE TRIGGER trg_prevent_genre_deletion
-BEFORE DELETE ON genre
-FOR EACH ROW
-EXECUTE FUNCTION prevent_genre_deletion();
Index: music/triggers/update_invoice_total_after_delete.sql
===================================================================
--- music/triggers/update_invoice_total_after_delete.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,19 +1,0 @@
-CREATE OR REPLACE FUNCTION update_invoice_total_after_delete()
-RETURNS TRIGGER AS $$
-BEGIN
-    UPDATE invoice
-    SET total = (
-        SELECT COALESCE(SUM(unit_price * quantity), 0)
-        FROM invoice_line
-        WHERE invoice_id = OLD.invoice_id
-    )
-    WHERE invoice_id = OLD.invoice_id;
-
-    RETURN OLD;
-END;
-$$ LANGUAGE plpgsql;
-
-CREATE TRIGGER trg_update_invoice_total_after_delete
-AFTER DELETE ON invoice_line
-FOR EACH ROW
-EXECUTE FUNCTION update_invoice_total_after_delete();
Index: music/triggers/update_invoice_total_after_insert.sql
===================================================================
--- music/triggers/update_invoice_total_after_insert.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,19 +1,0 @@
-CREATE OR REPLACE FUNCTION update_invoice_total_after_insert()
-RETURNS TRIGGER AS $$
-BEGIN
-    UPDATE invoice
-    SET total = (
-        SELECT COALESCE(SUM(unit_price * quantity), 0)
-        FROM invoice_line
-        WHERE invoice_id = NEW.invoice_id
-    )
-    WHERE invoice_id = NEW.invoice_id;
-
-    RETURN NEW;
-END;
-$$ LANGUAGE plpgsql;
-
-CREATE TRIGGER trg_update_invoice_total_after_insert
-AFTER INSERT ON invoice_line
-FOR EACH ROW
-EXECUTE FUNCTION update_invoice_total_after_insert();
Index: music/urls.py
===================================================================
--- music/urls.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ music/urls.py	(revision d7662b5c5695b63b885011417efd780494e2e537)
@@ -1,24 +1,9 @@
 from django.urls import path
-from django.views.generic import RedirectView
-
 from . import views
 
 urlpatterns = [
-    path('', views.home_page, name='homepage'),
     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('artist/avg-track-price', views.avg_price_per_artist, name='avg_track_price'),
-    path('artist/most-popular', views.rank_list_artists, name='rank_list_artists'),
     path('track/', views.track_list, name='track_list'),
-    path('customer/genres-per-customer', views.genres_per_customer, name='genres_per_customer'),
-    path('customer/invoices-per-customer', views.invoice_per_customer_after_date,
-         name='invoice_per_customer_after_date'),
-    path('customer/artist-per-genre', views.most_popular_artist_per_customer_per_genre,
-         name='most_popular_artist_per_customer_per_genre'),
-    path('customer/most-popular-genre-per-customer', views.most_listened_genre_per_customer,
-         name='most_listened_genre_per_customer'),
-    path('media-type/percentage', views.media_type_percentage, name='media_type_percentage'),
-    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'),
+    path('track/per_genre', views.tracks_count_per_genre, name='track_count_per_genre'),
 ]
Index: music/views.py
===================================================================
--- music/views.py	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ music/views.py	(revision d7662b5c5695b63b885011417efd780494e2e537)
@@ -3,5 +3,4 @@
 import django
 from django.db import connection
-from django.shortcuts import redirect
 
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MuiscOrganizationSystem.settings')
@@ -13,15 +12,8 @@
 # Create your views here.
 
-def home_page(request):
-    return render(request, 'home.html')
-
-def redirect_to_home(request, exception):
-    return redirect('home_page')
-
-## LIST OF ALL ##
 def album_list(request):
     heading = request.GET.get('model', 'All Albums')
     data = Album.objects.values_list('title', flat=True)
-    return render(request, 'list.html', {'data': data, 'heading': heading})
+    return render(request, 'album_list.html', {'data': data, 'heading': heading})
 
 
@@ -29,15 +21,7 @@
     heading = request.GET.get('model', 'All Tracks')
     data = Track.objects.values_list('name', flat=True)
-    return render(request, 'list.html', {'data': data, 'heading': heading})
+    return render(request, 'album_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)
-
-    return render(request, 'list.html', {'data': data, 'heading': heading})
-
-
-## VIEWS ##
 def tracks_count_per_genre(request):
     with connection.cursor() as cursor:
@@ -46,197 +30,12 @@
 
     data = [{'genre': row[0], 'count': row[1]} for row in rows]
+    print(data)
 
     return render(request, 'track_count_per_genre.html', {'data': data})
 
 
-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]
-
-    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})
-
-
-def avg_price_per_artist(request):
-    with connection.cursor() as cursor:
-        cursor.execute("SELECT * FROM avg_price_per_artist;")
-        rows = cursor.fetchall()
-
-    data = [{'name': row[0], 'avg_price_per_track': row[1]} for row in rows]
-
-    return render(request, 'avg_price_per_artist.html', {'data': data})
-
-
-def rank_list_artists(request):
-    with connection.cursor() as cursor:
-        cursor.execute("SELECT * FROM rank_list_artists;")
-        rows = cursor.fetchall()
-
-    data = [{'name': row[0], 'num_invoices': row[1], 'money_earned': row[2]} for row in rows]
-
-    return render(request, 'rank_list_artists.html', {'data': data})
-
-
-def media_type_percentage(request):
-    with connection.cursor() as cursor:
-        cursor.execute("SELECT * FROM media_type_percentage;")
-        rows = cursor.fetchall()
-
-    data = [{'name': row[0], 'num_of_tracks': row[1], 'percentage': row[2]} for row in rows]
-
-    return render(request, 'media_type_percentage.html', {'data': data})
-
-
-def most_listened_genre_per_customer(request):
-    with connection.cursor() as cursor:
-        cursor.execute("SELECT * FROM most_listened_genre_per_customer;")
-        rows = cursor.fetchall()
-
-    data = [{'first_name': row[0], 'last_name': row[1], 'most_listened_genre': row[2]} for row in rows]
-
-    return render(request, 'most_listened_genre_per_customer.html', {'data': data})
-
-
-## QUERRIES ##
-
-def genres_per_customer(request):
-    customers = Customer.objects.all()
-    selected_customer_id = request.GET.get('customer_id')
-    data = []
-    customer = None
-
-    if selected_customer_id:
-        customer = Customer.objects.filter(customer_id=selected_customer_id).first()
-        query = """
-            SELECT c.first_name as first_name, c.last_name as last_name, g.name as genre, COUNT(tr.track_id) as track_count
-            FROM customer c
-            LEFT JOIN invoice i ON c.customer_id = i.customer_id
-            LEFT JOIN invoice_line il ON i.invoice_id = il.invoice_id
-            LEFT JOIN track tr ON il.track_id = tr.track_id
-            LEFT JOIN genre g ON tr.genre_id = g.genre_id
-            WHERE c.customer_id = %s
-            GROUP BY c.customer_id, c.first_name, c.last_name, g.genre_id, g.name
-            ORDER BY c.first_name
-        """
-
-        with connection.cursor() as cursor:
-            cursor.execute(query, [selected_customer_id])
-            rows = cursor.fetchall()
-            data = [{'first_name': row[0], 'last_name': row[1], 'genre': row[2], 'track_count': row[3]} for row in rows]
-
-    return render(request, 'genres_per_customer.html', {
-        'customers': customers,
-        'data': data,
-        'customer': customer,
-        'selected_customer_id': selected_customer_id,
-    })
-
-def most_popular_artist_per_customer_per_genre(request):
-    customers = Customer.objects.all()
-    selected_customer_id = request.GET.get('customer_id')
-    data = []
-    customer = []
-    if selected_customer_id:
-        query = """WITH PlayCounts AS (
-                SELECT
-                    g.genre_id,
-                    g.name AS genre_name,
-                    ar.name AS artist_name,
-                    COUNT(*) AS play_count
-                FROM customer c
-                JOIN invoice i ON c.customer_id = i.customer_id
-                JOIN invoice_line il ON i.invoice_id = il.invoice_id
-                JOIN track tr ON il.track_id = tr.track_id
-                JOIN genre g ON tr.genre_id = g.genre_id
-                JOIN album a ON tr.album_id = a.album_id
-                JOIN artist ar ON a.artist_id = ar.artist_id
-                WHERE c.customer_id = %s
-                GROUP BY g.genre_id, g.name, ar.name
-            ),
-            MaxPlayCounts AS (
-                SELECT genre_id, MAX(play_count) AS max_count
-                FROM PlayCounts
-                GROUP BY genre_id
-            )
-            SELECT pc.genre_name, pc.artist_name, pc.play_count
-            FROM PlayCounts pc
-            JOIN MaxPlayCounts mpc ON pc.genre_id = mpc.genre_id AND pc.play_count = mpc.max_count;
-        """
-        customer = Customer.objects.filter(customer_id=selected_customer_id).first()
-
-        with connection.cursor() as cursor:
-            cursor.execute(query, [selected_customer_id])
-            rows = cursor.fetchall()
-            data = [{'genre': row[0], 'arist': row[1]} for row in rows]
-
-    return render(request, 'most_popular_artist_per_customer_per_genre.html', {
-        'customers': customers,
-        'customer': customer,
-        'data': data,
-        'selected_customer_id': selected_customer_id,
-    })
-
-
-def invoice_per_customer_after_date(request):
-    customers = Customer.objects.all()
-    selected_customer_id = request.GET.get('customer_id')
-    selected_date = request.GET.get('invoice_date', '2000-01-01')
-    data = []
-    sum = 0
-    customer = None
-
-    if selected_customer_id:
-        customer = Customer.objects.filter(customer_id=selected_customer_id).first()
-        if selected_date:
-            query = """
-                SELECT c.first_name, c.last_name, i.invoice_date::date, i.total
-                FROM customer c
-                JOIN invoice i ON c.customer_id = i.customer_id
-                WHERE c.customer_id = %s AND i.invoice_date > %s
-                ORDER BY i.invoice_date
-            """
-            with connection.cursor() as cursor:
-                cursor.execute(query, [selected_customer_id, selected_date])
-                rows = cursor.fetchall()
-                for r in rows:
-                    sum += r[3]
-
-                data = [{'first_name': row[0], 'last_name': row[1], 'invoice_date': row[2], 'total': row[3]} for row in
-                        rows]
-        else:
-            query = """
-                            SELECT c.first_name, c.last_name, i.invoice_date::date, i.total
-                            FROM customer c
-                            JOIN invoice i ON c.customer_id = i.customer_id
-                            WHERE c.customer_id = %s
-                            ORDER BY i.invoice_date
-                        """
-            with connection.cursor() as cursor:
-                cursor.execute(query, [selected_customer_id])
-                rows = cursor.fetchall()
-                for r in rows:
-                    sum += r[3]
-
-                data = [{'first_name': row[0], 'last_name': row[1], 'invoice_date': row[2], 'total': row[3]}
-                        for row in
-                        rows]
-
-    return render(request, 'invoices_per_customer_after_date.html', {
-        'customers': customers,
-        'total_sum': sum,
-        'data': data,
-        'customer': customer,
-        'selected_customer_id': selected_customer_id,
-    })
+def artist_list(request):
+    heading = request.GET.get('model', 'All Artists')
+    data = Artist.objects.values_list('name', flat=True)
+    print(data)
+    return render(request, 'album_list.html', {'data': data, 'heading': heading})
Index: music/views/avg_price_per_artist.sql
===================================================================
--- music/views/avg_price_per_artist.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,8 +1,0 @@
-CREATE VIEW avg_price_per_artist AS
-SELECT
-    ar.name,
-    COALESCE( ROUND(avg(t.unit_price), 2)::text, 'not enogu data') as avg_price_per_track
-FROM artist ar
-left join album a on ar.artist_id = a.artist_id
-left join track t on a.album_id = t.album_id
-group by ar.name
Index: music/views/avg_song_duration_per_artist.sql
===================================================================
--- music/views/avg_song_duration_per_artist.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,7 +1,0 @@
-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/media_type_percentage.sql
===================================================================
--- music/views/media_type_percentage.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,12 +1,0 @@
-CREATE VIEW media_type_percentage AS
-with cte as (SELECT count(track_id) as total
-             FROM media_type mt
-                      left join track tr on mt.media_type_id = tr.media_type_id)
-SELECT mt.name                                          as media_type,
-       count(tr.track_id)                               as num_of_tracks,
-       round(count(tr.track_id) * 100.0 / cte.total, 2) as percentage
-FROM media_type mt
-         left join track tr on mt.media_type_id = tr.media_type_id
-         cross join cte
-group by mt.media_type_id, mt.name, cte.total
-order by percentage desc
Index: music/views/most_listened_genre_per_customer.sql
===================================================================
--- music/views/most_listened_genre_per_customer.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,17 +1,0 @@
-CREATE VIEW most_listened_genre_per_customer AS
-WITH genre_count AS
-         (SELECT c.customer_id, c.first_name, c.last_name, g.name as genre, count(tr.track_id) as num_songs_per_genre
-          FROM customer c
-                   left join invoice i on c.customer_id = i.customer_id
-                   left join invoice_line il on i.invoice_id = il.invoice_id
-                   left join track tr on il.track_id = tr.track_id
-                   left join genre g on tr.genre_id = g.genre_id
-          group by c.customer_id, c.first_name, c.last_name, g.genre_id, g.name
-          order by c.first_name, num_songs_per_genre desc),
-     ranked_genres AS (SELECT *,
-                              ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY num_songs_per_genre DESC) AS rn
-                       FROM genre_count)
-SELECT first_name, last_name, genre as most_listened_genre
-FROM ranked_genres
-WHERE rn = 1
-ORDER BY first_name, last_name;
Index: music/views/rang_list_most_active_customers_view.sql
===================================================================
--- music/views/rang_list_most_active_customers_view.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,9 +1,0 @@
-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
Index: music/views/rank_list_artists.sql
===================================================================
--- music/views/rank_list_artists.sql	(revision 75ea229d549bcf10342f483dbb27e69334411131)
+++ 	(revision )
@@ -1,11 +1,0 @@
-CREATE VIEW rank_list_artists AS
-SELECT ar.name,
-       count(il.invoice_line_id) AS num_invoices,
-       COALESCE(SUM(i.total), 0) AS money_earned
-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
-         LEFT JOIN invoice_line il ON tr.track_id = il.track_id
-         LEFT JOIN invoice i on il.invoice_id = i.invoice_id
-GROUP BY ar.name
-ORDER BY money_earned DESC;
