From 153a4f6fc17b5e2091389cbbcbfe332b79ed9f14 Mon Sep 17 00:00:00 2001
From: Antoine Gaudron-desjardins <antoine.gaudrondesjardins@student-cs.fr>
Date: Fri, 8 Jul 2022 08:31:01 +0200
Subject: [PATCH] lint back

---
 backend/db/crud.py          | 19 ++++++++++++++-----
 backend/db/database.py      |  3 ++-
 backend/db/schemas.py       |  2 +-
 backend/docker-compose.yml  | 28 ++++++++++++++--------------
 backend/main.py             |  3 ---
 backend/routers/comments.py |  4 ++--
 backend/routers/news.py     |  2 +-
 backend/routers/stats.py    |  2 +-
 8 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/backend/db/crud.py b/backend/db/crud.py
index c460f2e..6315054 100644
--- a/backend/db/crud.py
+++ b/backend/db/crud.py
@@ -9,7 +9,7 @@ import pytz
 from db import models, schemas
 
 
-## Define CRUD operation to collect the statistics
+# Define CRUD operation to collect the statistics
 
 def get_waiting_time(place: str, db: Session):
     """ Get the last estimated waiting time for the given place """
@@ -61,14 +61,23 @@ def get_stats(place: str, weekday: int, min_time_hour: int, min_time_mn: int, ma
     return stats
 
 
-## Define CRUD operation for the comments
+# Define CRUD operation for the comments
 
 def get_comments(place: str, page: int, db: Session):
     """ Get  the 10 last comments for the given place """
     if page == 0:
         comments = db.query(models.Comments).order_by(models.Comments.date.desc(), models.Comments.id.desc()).all()
     else:
-        comments = db.query(models.Comments).filter(models.Comments.place == place).order_by(models.Comments.date.desc(), models.Comments.id.desc()).slice((page-1)*10, page*10).all()
+        comments = db.query(
+            models.Comments).filter(
+            models.Comments.place == place).order_by(
+            models.Comments.date.desc(),
+            models.Comments.id.desc()).slice(
+                (page -
+                 1) *
+                10,
+                page *
+            10).all()
     return comments
 
 
@@ -91,7 +100,7 @@ def delete_comment(id: int, db: Session):
     db.commit()
 
 
-## Define CRUD operation for the news
+# Define CRUD operation for the news
 
 def get_news(place: str, db: Session):
     """ Get the news for the given place """
@@ -115,4 +124,4 @@ def delete_news(id: int, db: Session):
         db.query(models.News).delete()
     else:
         db.query(models.News).filter(models.News.id == id).delete()
-    db.commit()
\ No newline at end of file
+    db.commit()
diff --git a/backend/db/database.py b/backend/db/database.py
index eed306e..0a83d51 100644
--- a/backend/db/database.py
+++ b/backend/db/database.py
@@ -22,10 +22,11 @@ SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
 
 Base = declarative_base()
 
+
 def get_db():
     """Create a database session."""
     db = SessionLocal()
     try:
         yield db
     finally:
-        db.close()
\ No newline at end of file
+        db.close()
diff --git a/backend/db/schemas.py b/backend/db/schemas.py
index edb7b33..71fe821 100644
--- a/backend/db/schemas.py
+++ b/backend/db/schemas.py
@@ -51,4 +51,4 @@ class News(NewsBase):
     published_at: datetime = Field(..., title="Publication date of the news")
 
     class Config:
-        orm_mode = True
\ No newline at end of file
+        orm_mode = True
diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml
index 1ee257b..4cb18fd 100644
--- a/backend/docker-compose.yml
+++ b/backend/docker-compose.yml
@@ -17,20 +17,20 @@ services:
     volumes:
       - mysql-db:/var/lib/mysql
 
-  app:
-    build: . 
-    container_name: "app"
-    depends_on:
-      db: 
-        condition: service_healthy
-    restart: always
-    ports:
-      - 8000:80
-    env_file: .env
-    environment:
-      DB_HOST: db
-    links:
-      - db
+  # app:
+  #   build: . 
+  #   container_name: "app"
+  #   depends_on:
+  #     db: 
+  #       condition: service_healthy
+  #   restart: always
+  #   ports:
+  #     - 8000:80
+  #   env_file: .env
+  #   environment:
+  #     DB_HOST: db
+  #   links:
+  #     - db
 
 volumes:
   mysql-db:
\ No newline at end of file
diff --git a/backend/main.py b/backend/main.py
index 21db8ec..d4d2ed4 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -36,9 +36,6 @@ app.include_router(comments.router)
 app.include_router(news.router)
 
 
-
-
-
 """
 import cv2
 import numpy as np
diff --git a/backend/routers/comments.py b/backend/routers/comments.py
index ee7ce9d..0e44fbd 100644
--- a/backend/routers/comments.py
+++ b/backend/routers/comments.py
@@ -10,7 +10,7 @@ router = APIRouter(prefix="/api/comments", tags=["comments"])
 
 
 @router.get('/{place}', response_model=List[schemas.Comment])
-async def get_comments(place: str, page: int=1, db: Session = Depends(get_db)):
+async def get_comments(place: str, page: int = 1, db: Session = Depends(get_db)):
     return crud.get_comments(place, page, db)
 
 
@@ -21,4 +21,4 @@ async def create_comment(place: str, comment: schemas.CommentBase, db: Session =
 
 @router.delete('/{id}', response_model=None)
 async def delete_comment(id: int, db: Session = Depends(get_db)):
-    return crud.delete_comment(id, db)
\ No newline at end of file
+    return crud.delete_comment(id, db)
diff --git a/backend/routers/news.py b/backend/routers/news.py
index 4d0bd3e..8e8ecfb 100644
--- a/backend/routers/news.py
+++ b/backend/routers/news.py
@@ -21,4 +21,4 @@ async def create_news(place: str, news: schemas.NewsBase, db: Session = Depends(
 
 @router.delete('/{id}', response_model=None)
 async def delete_news(id: int, db: Session = Depends(get_db)):
-    return crud.delete_news(id, db)
\ No newline at end of file
+    return crud.delete_news(id, db)
diff --git a/backend/routers/stats.py b/backend/routers/stats.py
index 69bc337..092a062 100644
--- a/backend/routers/stats.py
+++ b/backend/routers/stats.py
@@ -18,4 +18,4 @@ async def waiting_time(place: str, db: Session = Depends(get_db)):
 @router.get('/{place}/stats/{day}/{min_time_hour}/{min_time_mn}/{max_time_hour}/{max_time_mn}/{interval}', response_model=list)
 async def stats(place: str, day: int, min_time_hour: int, min_time_mn: int,
                 max_time_hour: int, max_time_mn: int, interval: timedelta, db: Session = Depends(get_db)):
-    return crud.get_stats(place, day, min_time_hour, min_time_mn, max_time_hour, max_time_mn, interval, db)
\ No newline at end of file
+    return crud.get_stats(place, day, min_time_hour, min_time_mn, max_time_hour, max_time_mn, interval, db)
-- 
GitLab