Skip to content

Commit

Permalink
Merge pull request #43 from bendsouza2/enhancement/backend-ec2-integr…
Browse files Browse the repository at this point in the history
…ation

Enhancement/backend ec2 integration
  • Loading branch information
bendsouza2 authored Dec 20, 2024
2 parents 4e83d71 + 144ddb9 commit dc9a37e
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 40 deletions.
4 changes: 3 additions & 1 deletion app/django-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ google-auth-httplib2==0.1.0
google-auth-oauthlib==1.2.1
Django==5.1.3
djangorestframework==3.15.2
pillow==10.2.0
pillow==10.2.0
mysqlclient==2.2.6
gunicorn==23.0.0
4 changes: 2 additions & 2 deletions app/today/management/commands/upload_youtube_short.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.core.management.base import BaseCommand
from django.utils import timezone

from today.models import Sentences
from today.models import Video
from python.main import process_video_and_upload


Expand All @@ -15,7 +15,7 @@ def handle(self, *args, **options):

video_details = process_video_and_upload()

sentence, created = Sentences.objects.update_or_create(
sentence, created = Video.objects.update_or_create(
video_id=video_details["video_id"],
defaults={
"word": video_details["word"],
Expand Down
42 changes: 15 additions & 27 deletions app/today/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,8 @@


class Video(models.Model):
video_id = models.CharField(max_length=50, unique=True)
title = models.CharField(max_length=200)
description = models.TextField()
thumbnail_url = models.URLField()
upload_date = models.DateTimeField(default="2024-11-05T15:41:31Z")

def __str__(self):
return self.video_id


class Sentences(models.Model):
video_id = models.CharField(max_length=50, unique=True)
word = models.CharField(max_length=25)
sentence = models.CharField(max_length=300)
translated_sentence = models.CharField(max_length=300)


class VideoDetails(models.Model):
"""
Model combining video metadata and associated word/sentence data.
Fields:
video_id (CharField): Unique identifier for the video generated by YouTube.
word (CharField): Key word within the associated sentence.
Expand All @@ -34,11 +15,18 @@ class VideoDetails(models.Model):
description (TextField): Description of the video content.
upload_date (DateTimeField): Date and time of the video upload.
"""
video_id = models.CharField(max_length=50, unique=True)
word = models.CharField(max_length=25)
sentence = models.CharField(max_length=300)
translated_sentence = models.CharField(max_length=300)
title = models.CharField(max_length=200)
description = models.TextField()
upload_date = models.DateTimeField()
thumbnail_url = models.URLField()
video_id = models.CharField(max_length=255, unique=True, primary_key=True)
word = models.CharField(max_length=25, null=True, blank=True)
sentence = models.CharField(max_length=300, null=True, blank=True)
translated_sentence = models.CharField(max_length=300, null=True, blank=True)
title = models.CharField(max_length=100, null=True, blank=True)
description = models.TextField(null=True, blank=True)
upload_time = models.DateTimeField(null=True, blank=True)
thumbnail_url = models.URLField(null=True, blank=True)

def __str__(self):
return self.video_id

class Meta:
db_table = "videos"

4 changes: 2 additions & 2 deletions app/today/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework import serializers

from today.models import VideoDetails
from today.models import Video


class VideoDetailsSerializer(serializers.ModelSerializer):
Expand All @@ -19,7 +19,7 @@ class VideoDetailsSerializer(serializers.ModelSerializer):
thumbnail_url (str): URL of the video's thumbnail image.
"""
class Meta:
model = VideoDetails
model = Video
fields = [
"video_id",
"word",
Expand Down
6 changes: 3 additions & 3 deletions app/today/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
from rest_framework.response import Response
from rest_framework import status

from today.models import Video, VideoDetails
from today.models import Video
from today.serializers import VideoDetailsSerializer


class VideoDetailsViewSet(viewsets.ModelViewSet):
"""
API endpoint for retrieving and manipulating VideoDetails instances
Provides standard CRUD operations on VideoDetails data.
Provides standard CRUD operations on Video data.
"""
queryset = VideoDetails.objects.all()
queryset = Video.objects.all()
serializer_class = VideoDetailsSerializer

@action(detail=False, methods=["get"], url_path="latest")
Expand Down
24 changes: 23 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"dependencies": {
"axios": "^1.7.7",
"core-js": "^3.8.3",
"vue": "^3.2.13"
"vue": "^3.2.13",
"vue-router": "^4.5.0"
},
"devDependencies": {
"@babel/core": "^7.12.16",
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { createApp } from 'vue'
import App from './App.vue'
import { createApp } from 'vue';
import App from './App.vue';
import router from './router';

createApp(App).mount('#app')
const app = createApp(App);
app.use(router);
app.mount('#app');
20 changes: 20 additions & 0 deletions frontend/src/router/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createRouter, createWebHistory } from 'vue-router';
import LatestVideo from '@/components/LatestVideo.vue';

const routes = [
{
path: '/',
redirect: '/today/api/videos/latest',
},
{
path: '/today/api/videos/latest',
component: LatestVideo,
},
];

const router = createRouter({
history: createWebHistory(),
routes,
});

export default router;

0 comments on commit dc9a37e

Please sign in to comment.