Skip to content

Commit

Permalink
fixed linting errors in userpage
Browse files Browse the repository at this point in the history
  • Loading branch information
sd-20 committed Nov 17, 2022
1 parent 6e4a2a6 commit 8df46f3
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions src/backend/pages/userpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
class UserPage:
"""UserPage class"""

def __init__(self, username: str, user:User) -> None:
def __init__(self, username: str) -> None:
"""Constructor"""
self.username = username
self.user = self.get_user(self, username)

self.user = self.get_user(username)

<<<<<<< HEAD
@use_database
def get_user(self, username: str):
"""Return User object based on username"""
Expand All @@ -26,16 +24,10 @@ def get_user(self, username: str):
WHERE u.username = ?",
(query_sql,),
).fetchone()

if user_query is None: return None
else:
user_id, password, email, phone = user_query
return User(user_id, username, password, email, phone)
=======
def get_user(self):
"""Return User object based on self.username"""
return True
>>>>>>> 54a7f6a760774b09fd9933a99f61c01ee41785c4
if user_query is None:
return None
user_id, password, email, phone = user_query
return User(user_id, username, password, email, phone)

@use_database
def update_password(self, password: str) -> bool:
Expand All @@ -50,28 +42,21 @@ def update_password(self, password: str) -> bool:
WHERE user_id = ?",
(password, query_sql),
)

return True

@use_database
def update_email(self, email: str) -> bool:
<<<<<<< HEAD
"""Updates email based on username"""
if self.user.email == email:
return True
=======
"""Updates email based on self.username"""
return True
>>>>>>> 54a7f6a760774b09fd9933a99f61c01ee41785c4

query_sql = "%" + email + "%"
self.update_email.cursor.execute(
"UPDATE Users \
SET email = ? \
WHERE username = ?",
(query_sql,self.username),
(query_sql, self.username),
)

new_email = self.update_email.cursor.execute(
"SELECT email \
From User \
Expand All @@ -96,8 +81,16 @@ def get_liked(self, user_id: int) -> List[Apt]:

for apt in liked:
apt_id, apt_name, apt_address, price_min, price_max = apt
apts.append(Apt(apt_id, apt_name, apt_address, price_min, price_max))

query_sql = "%" + apt_id + "%"
rating = self.get_liked.cursor.execute(
"SELECT AVG(r.vote) \
From Reviews r \
WHERE r.apt_id = ?",
(query_sql),
)
apts.append(
Apt(apt_id, apt_name, rating, apt_address, price_min, price_max)
)
return apts

@use_database
Expand Down

3 comments on commit 8df46f3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py131894%57, 71, 74–76, 78, 86–87
config.py10100% 
decorators.py270100% 
dataholders
   apt.py90100% 
   mainpage_get.py150100% 
   review.py70100% 
   user.py80100% 
pages
   login.py350100% 
   mainpage.py1000100% 
   userpage.py502158%29–30, 37–45, 50–67, 72–94
TOTAL3832992% 

Tests Skipped Failures Errors Time
42 0 💤 1 ❌ 0 🔥 0.852s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py131894%57, 71, 74–76, 78, 86–87
config.py10100% 
decorators.py270100% 
dataholders
   apt.py90100% 
   mainpage_get.py150100% 
   review.py70100% 
   user.py80100% 
pages
   login.py350100% 
   mainpage.py1000100% 
   userpage.py502158%29–30, 37–45, 50–67, 72–94
TOTAL3832992% 

Tests Skipped Failures Errors Time
42 0 💤 1 ❌ 0 🔥 1.057s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py131894%57, 71, 74–76, 78, 86–87
config.py10100% 
decorators.py270100% 
dataholders
   apt.py90100% 
   mainpage_get.py150100% 
   review.py70100% 
   user.py80100% 
pages
   login.py350100% 
   mainpage.py1000100% 
   userpage.py502158%29–30, 37–45, 50–67, 72–94
TOTAL3832992% 

Tests Skipped Failures Errors Time
42 0 💤 1 ❌ 0 🔥 1.103s ⏱️

Please sign in to comment.