Skip to content

Commit

Permalink
BUG: Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mseng10 committed Jul 13, 2024
1 parent 5ff0ed9 commit 6e8deea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from sqlalchemy.engine import URL

# Local application imports
from models.plant import Plant, Genus, Type, Base
from models.plant import Plant, Genus, Type
from models.system import System, Light
from models.alert import PlantAlert, Todo

Expand Down Expand Up @@ -366,16 +366,16 @@ def alert_check():
# Return JSON response
return jsonify(alerts_json)

@app.route("/todo/<int:id>/resolve", methods=["POST"])
def todo_resolve(id):
@app.route("/todo/<int:todo_id>/resolve", methods=["POST"])
def todo_resolve(todo_id):
"""
Resolves the plant alert.
"""
# Log the request
logger.info("Received request to resolve plant alert")
session = Session()

todo = session.query(Todo).get(id)
todo = session.query(Todo).get(todo_id)
todo.resolved = True
todo.resolved_on = datetime.now()

Expand Down
10 changes: 7 additions & 3 deletions server/models/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

# Standard library imports
from datetime import datetime
from typing import List

# Third-party imports
from sqlalchemy import Column, Integer, String, DateTime, Boolean, ForeignKey
from sqlalchemy.orm import Mapped, relationship, mapped_column
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Mapped, mapped_column
from models.plant import Base

class Todo(Base):
Expand All @@ -26,6 +24,9 @@ class Todo(Base):
name = Column(String(100), nullable=False)
description = Column(String(400), nullable=True)

def __repr__(self):
return f"{self.name}"

def to_json(self):
"""Convert to json."""
return {
Expand Down Expand Up @@ -58,6 +59,9 @@ class PlantAlert(Base):
) # System this light belongs to
alert_type = Column(String(400), nullable=False)

def __repr__(self):
return f"{self.alert_type}"

def to_json(self):
"""Convert to json."""
return {
Expand Down

0 comments on commit 6e8deea

Please sign in to comment.