Browse Source

Fixed issues with storing huge video count in the database

sleepytaco 3 years ago
parent
commit
30e2ccefe0

+ 43 - 0
apps/main/migrations/0002_auto_20211204_0521.py

@@ -0,0 +1,43 @@
+# Generated by Django 3.2.6 on 2021-12-04 05:21
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('main', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='playlist',
+            name='playlist_duration_in_seconds',
+            field=models.BigIntegerField(default=0),
+        ),
+        migrations.AlterField(
+            model_name='video',
+            name='comment_count',
+            field=models.BigIntegerField(default=0),
+        ),
+        migrations.AlterField(
+            model_name='video',
+            name='dislike_count',
+            field=models.BigIntegerField(default=0),
+        ),
+        migrations.AlterField(
+            model_name='video',
+            name='duration_in_seconds',
+            field=models.BigIntegerField(default=0),
+        ),
+        migrations.AlterField(
+            model_name='video',
+            name='like_count',
+            field=models.BigIntegerField(default=0),
+        ),
+        migrations.AlterField(
+            model_name='video',
+            name='view_count',
+            field=models.BigIntegerField(default=0),
+        ),
+    ]

+ 6 - 6
apps/main/models.py

@@ -1266,7 +1266,7 @@ class Video(models.Model):
     video_id = models.CharField(max_length=100)
     name = models.CharField(max_length=100, blank=True)
     duration = models.CharField(max_length=100, blank=True)
-    duration_in_seconds = models.IntegerField(default=0)
+    duration_in_seconds = models.BigIntegerField(default=0)
     thumbnail_url = models.TextField(blank=True)
     published_at = models.DateTimeField(blank=True, null=True)
     description = models.TextField(default="")
@@ -1275,10 +1275,10 @@ class Video(models.Model):
 
     # video stats
     public_stats_viewable = models.BooleanField(default=True)
-    view_count = models.IntegerField(default=0)
-    like_count = models.IntegerField(default=0)
-    dislike_count = models.IntegerField(default=0)
-    comment_count = models.IntegerField(default=0)
+    view_count = models.BigIntegerField(default=0)
+    like_count = models.BigIntegerField(default=0)
+    dislike_count = models.BigIntegerField(default=0)
+    comment_count = models.BigIntegerField(default=0)
 
     yt_player_HTML = models.TextField(blank=True)
 
@@ -1343,7 +1343,7 @@ class Playlist(models.Model):
     playlist_yt_player_HTML = models.TextField(blank=True)
 
     playlist_duration = models.CharField(max_length=69, blank=True)  # string version of playlist dureation
-    playlist_duration_in_seconds = models.IntegerField(default=0)
+    playlist_duration_in_seconds = models.BigIntegerField(default=0)
 
     # watch playlist details
     # watch_time_left = models.CharField(max_length=150, default="")

+ 2 - 2
apps/main/templates/home.html

@@ -2,7 +2,7 @@
 {% extends 'base.html' %}
 {% load humanize %}
 {% block content %}
-    {% if user.playlists.all.count|add:"-1" >= -1 %}
+    {% if user.playlists.all.count|add:"-1" <= -1 %}
         <div class="alert alert-success" role="alert">
             <h4 class="alert-heading">It's empty in here</h4>
             <p>
@@ -49,7 +49,7 @@
             <div class="col-6 mb-4">
                 <div class="card bg-transparent text-dark">
                     <div class="card-body">
-                        <h6 class="d-flex justify-content-center align-items-center mb-3">You have a total of <span class="text-warning ms-1 me-1">{{ user.playlists.count|add:"-1" }}</span> Playlists in your UnTube collection</h6>
+                        <h6 class="d-flex justify-content-center align-items-center mb-3">You have a total of <span class="text-warning ms-1 me-1">{{ user.playlists.count }}</span> Playlists in your UnTube collection</h6>
                         <div class="d-flex align-items-center mb-3">
 
                             <canvas id="overall-playlists-distribution" data-url="{% url 'overall_playlists_distribution' %}">

+ 3 - 3
apps/users/templates/index.html

@@ -200,10 +200,10 @@
     Some more features:
 </h1>
   <h3>
-      <span style="border-bottom: 4px #c2d56b dashed;">merging multiple playlists into one</span>,
+      <span style="border-bottom: 4px #c2d56b dashed;">take notes on videos</span>,
   </h3>
 <h3>
-      <span style="border-bottom: 4px #c2d56b dashed;">deleting multiple playlists at once</span>,
+      <span style="border-bottom: 4px #c2d56b dashed;">filter and sort playlists/videos</span>,
   </h3>
     <h3>
       <span style="border-bottom: 4px #c2d56b dashed;">auto-update your playlists with YouTube</span>,
@@ -249,7 +249,7 @@
           </a>
           -->
                     <small><i class="fas fa-circle fa-sm"></i></small>
-        <i class="fab fa-github fa-lg" style="color: black;"></i>
+        <a style="text-decoration: none; color: black" href="https://github.com/sleepytaco/UnTube" target="_blank"><i class="fab fa-github fa-lg" style="color: black;"></i></a>
           <small><i class="fas fa-circle fa-sm"></i></small>
           <a {% if request.session.liked_untube %}hx-post="{% url 'unlike_untube' %}"{% else %}hx-post="{% url 'like_untube' %}"{% endif %} hx-trigger="click" hx-swap="outerHTML" style="text-decoration: none; color: black">
             <i class="fas fa-heart" {% if request.session.liked_untube %}style="color: #d02e2e"{% endif %}></i> {{ likes }} likes {% if not request.session.liked_untube %}(click it){% endif %}