From 942f9c444091ea10856f158df363d1c4561486eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Mon, 22 Jul 2024 09:15:39 -0300 Subject: [PATCH 01/16] Create vercel.json --- vercel.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 vercel.json diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..de4c087 --- /dev/null +++ b/vercel.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "builds": [ + { "src": "src/main.py", "use": "@vercel/python" } + ], + "routes": [ + { "src": "/(.*)", "dest": "src/main.py" } + ], +} From b70bfc66cb4fd2e32366d366b934e7ab93c14f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Mon, 22 Jul 2024 09:19:06 -0300 Subject: [PATCH 02/16] Update vercel.json --- vercel.json | 1 - 1 file changed, 1 deletion(-) diff --git a/vercel.json b/vercel.json index de4c087..81f4d5c 100644 --- a/vercel.json +++ b/vercel.json @@ -1,5 +1,4 @@ { - "version": 2, "builds": [ { "src": "src/main.py", "use": "@vercel/python" } ], From b690f9a0755f96e4ed29c5469b84b7d88c6e5d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Mon, 22 Jul 2024 09:21:33 -0300 Subject: [PATCH 03/16] Update vercel.json --- vercel.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vercel.json b/vercel.json index 81f4d5c..633ed10 100644 --- a/vercel.json +++ b/vercel.json @@ -3,6 +3,6 @@ { "src": "src/main.py", "use": "@vercel/python" } ], "routes": [ - { "src": "/(.*)", "dest": "src/main.py" } + { "src": "src/(.*)", "dest": "src/main.py" } ], } From 949fc4338a284a67bfb39e36c438984099a9b514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Mon, 22 Jul 2024 09:25:07 -0300 Subject: [PATCH 04/16] Update vercel.json --- vercel.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vercel.json b/vercel.json index 633ed10..b6d0c9b 100644 --- a/vercel.json +++ b/vercel.json @@ -4,5 +4,5 @@ ], "routes": [ { "src": "src/(.*)", "dest": "src/main.py" } - ], + ] } From d7382754ac52f393f942af03baaffbdb70b34dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Mon, 22 Jul 2024 09:30:35 -0300 Subject: [PATCH 05/16] Update vercel.json --- vercel.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vercel.json b/vercel.json index b6d0c9b..c6e83ea 100644 --- a/vercel.json +++ b/vercel.json @@ -3,6 +3,6 @@ { "src": "src/main.py", "use": "@vercel/python" } ], "routes": [ - { "src": "src/(.*)", "dest": "src/main.py" } + { "src": "/(.*)", "dest": "src/main.py" } ] } From 6cc5aed5d6716c13d48c1aab7cb17a507ee86e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Mon, 22 Jul 2024 09:33:10 -0300 Subject: [PATCH 06/16] Update main.py --- src/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index 8fde837..45ff340 100644 --- a/src/main.py +++ b/src/main.py @@ -5,7 +5,7 @@ load_dotenv() -from controller import commentController, scheduleController +from src.controller import scheduleController # Desativado os os comentarios nos videos # from database import SessionLocal, engine @@ -37,4 +37,4 @@ async def root(): if (len(sys.argv) == 2): port = sys.argv[1] - uvicorn.run('main:app', reload=True, port=int(port), host="0.0.0.0") \ No newline at end of file + uvicorn.run('main:app', reload=True, port=int(port), host="0.0.0.0") From ce298eefb5d47d0cbfef6f9fb049655a30a8f242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Mon, 22 Jul 2024 09:35:25 -0300 Subject: [PATCH 07/16] Update scheduleController.py --- src/controller/scheduleController.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controller/scheduleController.py b/src/controller/scheduleController.py index 9a955a0..ead291c 100644 --- a/src/controller/scheduleController.py +++ b/src/controller/scheduleController.py @@ -5,8 +5,8 @@ from unidecode import unidecode from starlette.responses import JSONResponse -from utils import enumeration -from constants import errorMessages +from src.utils import enumeration +from src.constants import errorMessages schedule = APIRouter( prefix="/schedule" From ae51c271716cc449555ad0ede22b5091365e58f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Sun, 28 Jul 2024 18:43:57 -0300 Subject: [PATCH 08/16] Create merge.yml --- .github/workflows/merge.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/merge.yml diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml new file mode 100644 index 0000000..bbdfb85 --- /dev/null +++ b/.github/workflows/merge.yml @@ -0,0 +1,33 @@ +name: Merge Repositories + +on: [repository_dispatch] + +jobs: + sync_with_upstream: + runs-on: ubuntu-latest + environment: actions + + steps: + - name: Checkout fork + uses: actions/checkout@v3 + with: + repository: victorleaoo/2024.1-UnB-TV-VideoService + ref: develop + token: ${{ secrets.API_GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Configure Git user + run: | + git config --global user.email "action@github.com" + git config --global user.name "GitHub Action" + + - name: Add and fetch upstream + run: | + git remote add upstream https://github.com/fga-eps-mds/2024.1-UnB-TV-VideoService.git + git fetch upstream + + - name: Merge upstream changes + run: | + git checkout develop + git merge upstream/develop --no-ff + git push origin develop --force From 1ddb26c14fb8b48db9413ec52fa913547319e7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Sun, 4 Aug 2024 13:20:30 -0300 Subject: [PATCH 09/16] Update database.py --- src/database.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/database.py b/src/database.py index 923804f..9f62c68 100644 --- a/src/database.py +++ b/src/database.py @@ -2,13 +2,14 @@ from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, declarative_base -POSTGRES_USER = os.getenv("POSTGRES_USER") -POSTGRES_PASSWORD = os.getenv("POSTGRES_PASSWORD") -POSTGRES_HOST = os.getenv("POSTGRES_HOST") -POSTGRES_DB = os.getenv("POSTGRES_DB") -POSTGRES_PORT = os.getenv("POSTGRES_PORT", default=5432) +# POSTGRES_USER = os.getenv("POSTGRES_USER") +# POSTGRES_PASSWORD = os.getenv("POSTGRES_PASSWORD") +# POSTGRES_HOST = os.getenv("POSTGRES_HOST") +# POSTGRES_DB = os.getenv("POSTGRES_DB") +# POSTGRES_PORT = os.getenv("POSTGRES_PORT", default=5432) -POSTGRES_URI = f'postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DB}' +POSTGRES_URI = os.getenv("POSTGRES_URL") +#postgresql://unbtv:z66y7sfFA8uEGf5t7LQc2fP2UUTxzMhe@dpg-cqf64o0gph6c73b7iasg-a/unbtv engine = create_engine(POSTGRES_URI) @@ -21,4 +22,4 @@ def get_db(): try: yield db finally: - db.close() \ No newline at end of file + db.close() From 4407ac02a2239b6a4f1a492c569ee0d324021ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Tue, 6 Aug 2024 14:35:12 -0300 Subject: [PATCH 10/16] Update database.py From 4c4d01eb9f62d2fa55011c4f2a40d47ffc14f1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Tue, 6 Aug 2024 14:50:51 -0300 Subject: [PATCH 11/16] Update main.py --- src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 6840135..537c4a8 100755 --- a/src/main.py +++ b/src/main.py @@ -2,7 +2,7 @@ from fastapi import FastAPI from dotenv import load_dotenv from fastapi.middleware.cors import CORSMiddleware -from database import init_db # Adicione a função de inicialização do banco de dados +from src.database import init_db # Adicione a função de inicialização do banco de dados From 10545266673993a927b313444699826c4d7a61f9 Mon Sep 17 00:00:00 2001 From: victorleaoo Date: Tue, 6 Aug 2024 14:54:51 -0300 Subject: [PATCH 12/16] arrumando os src pra deploy --- src/controller/savedVideosController.py | 6 +++--- src/model/savedVideosModel.py | 2 +- src/repository/savedVideosRepository.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controller/savedVideosController.py b/src/controller/savedVideosController.py index 7be5d04..75ec7c1 100644 --- a/src/controller/savedVideosController.py +++ b/src/controller/savedVideosController.py @@ -1,8 +1,8 @@ from fastapi import APIRouter, HTTPException, Depends, Query from sqlalchemy.orm import Session -from domain import savedVideosSchema -from database import get_db -from repository import savedVideosRepository +from src.domain import savedVideosSchema +from src.database import get_db +from src.repository import savedVideosRepository from starlette.responses import JSONResponse WatchLater = APIRouter( diff --git a/src/model/savedVideosModel.py b/src/model/savedVideosModel.py index 9374f02..02bd136 100644 --- a/src/model/savedVideosModel.py +++ b/src/model/savedVideosModel.py @@ -1,6 +1,6 @@ import uuid from sqlalchemy import Column, String, Boolean -from database import Base +from src.database import Base class WatchLater(Base): __tablename__ = 'watch_later' diff --git a/src/repository/savedVideosRepository.py b/src/repository/savedVideosRepository.py index 1e63518..d5a9c91 100644 --- a/src/repository/savedVideosRepository.py +++ b/src/repository/savedVideosRepository.py @@ -1,7 +1,7 @@ from sqlalchemy.orm import Session -from domain import savedVideosSchema -from model import savedVideosModel +from src.domain import savedVideosSchema +from src.model import savedVideosModel from fastapi import HTTPException def create_watch_later(db: Session, watch_later: savedVideosSchema.WatchLaterCreate): From db740c21080a6bd317b1eb972e0442e56e20cf42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Sat, 10 Aug 2024 23:26:30 -0300 Subject: [PATCH 13/16] Update main.py --- src/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 537c4a8..9bdc0a6 100755 --- a/src/main.py +++ b/src/main.py @@ -8,7 +8,7 @@ load_dotenv() -from src.controller import scheduleController, savedVideosController +from src.controller import scheduleController, savedVideosController, recordController from src.controller.savedVideosController import WatchLater # Desativado os os comentarios nos videos @@ -37,6 +37,7 @@ #app.include_router(prefix="/api", router=commentController.comment) app.include_router(prefix="/api", router=scheduleController.schedule) app.include_router(prefix="/api", router=savedVideosController.favorite) +app.include_router(prefix="/api", router=recordController.Record) @app.get("/") async def root(): From 472cc4833737d722792bda13f7e82c26099f4319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Sat, 10 Aug 2024 23:27:41 -0300 Subject: [PATCH 14/16] Create recordModel.py --- src/model/recordModel.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/model/recordModel.py diff --git a/src/model/recordModel.py b/src/model/recordModel.py new file mode 100644 index 0000000..981fc4c --- /dev/null +++ b/src/model/recordModel.py @@ -0,0 +1,10 @@ +import uuid +from sqlalchemy import Column, String, JSON +from database import Base + +class Record(Base): + __tablename__ = 'record' + id = Column(String, primary_key=True, index=True, default=lambda: str(uuid.uuid4())) + user_id = Column(String, index=True, nullable=False) + videos = Column(JSON, nullable=False) + From ccfcff8d6378bcc8ade3710a265643d8e7b0cad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Sat, 10 Aug 2024 23:28:16 -0300 Subject: [PATCH 15/16] Create recordController.py --- src/controller/recordController.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/controller/recordController.py diff --git a/src/controller/recordController.py b/src/controller/recordController.py new file mode 100644 index 0000000..bbf4b57 --- /dev/null +++ b/src/controller/recordController.py @@ -0,0 +1,25 @@ +from fastapi import APIRouter, HTTPException, Depends, Query +from sqlalchemy.orm import Session +from domain import recordSchema +from database import get_db +from repository import recordRepository +from starlette.responses import JSONResponse + +Record = APIRouter( + prefix="/record" +) + +@Record.post("/") +def add_to_record(record: recordSchema.RecordCreate, db: Session = Depends(get_db)): + record_user = recordSchema.RecordGet(user_id =record.user_id) + videos = recordRepository.get_record(db = db, record = record_user) + if videos: + return recordRepository.create_record(db=db, record=record, is_create= False) + + return recordRepository.create_record(db=db, record=record, is_create= True) + +@Record.get("/get_record") +def check_record(user_id: str =Query(...) , db: Session = Depends(get_db)): + record = recordSchema.RecordGet(user_id =user_id) + videos = recordRepository.get_record(db=db, record=record) + return {"videos": videos} From e39981f77a19203c14830afd86e30f710e077fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Le=C3=A3o?= Date: Sat, 10 Aug 2024 23:28:41 -0300 Subject: [PATCH 16/16] Create recordSchema.py --- src/domain/recordSchema.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/domain/recordSchema.py diff --git a/src/domain/recordSchema.py b/src/domain/recordSchema.py new file mode 100644 index 0000000..439e550 --- /dev/null +++ b/src/domain/recordSchema.py @@ -0,0 +1,12 @@ +from pydantic import BaseModel +from typing import Dict + +class RecordBase(BaseModel): + user_id: str + videos: Dict[str, str] + +class RecordCreate(RecordBase): + pass + +class RecordGet(BaseModel): + user_id: str