Skip to content

Commit

Permalink
happiness wrapped endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanjma committed Dec 31, 2024
1 parent 1346e56 commit 7ea8f12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion happiness-backend/api/dao/happiness_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get_filter_by_params(user_id: int, start: datetime, end: datetime, low: floa
query = query.where(Happiness.value >= low, Happiness.value <= high)
has_filtered = True
if text is not None:
query = query.where(Happiness.comment.like(f"%{text}%"))
query = query.where(Happiness.comment.ilike(f"%{text}%"))
has_filtered = True
return query, has_filtered

Expand Down
13 changes: 13 additions & 0 deletions happiness-backend/api/routes/happiness.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime

import requests
from apifairy import authenticate, body, arguments, response, other_responses
from flask import Blueprint, current_app

Expand Down Expand Up @@ -309,3 +310,15 @@ def count_multi_filter_search_happiness(req):
token_auth.current_user().has_mutual_group(users_dao.get_user_by_id(user_id))):
return failure_response("Not Allowed.", 403)
return {"number": happiness_dao.get_num_happiness_by_filter(user_id, start, end, low, high, text)}

@happiness.get('/wrapped')
@authenticate(token_auth)
@other_responses({400: "Not Allowed."})
def get_wrapped():
"""
Get Happiness App Wrapped Data
"""
all_wrapped_data = requests.get(current_app.config["WRAPPED_DATA_URL"]).json()
if str(token_current_user().id) in all_wrapped_data.keys():
return all_wrapped_data[str(token_auth.current_user().id)]
return failure_response("Not Allowed.", 400)
6 changes: 4 additions & 2 deletions happiness-backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Config:

# Security measures
SECRET_KEY = os.environ.get("SECRET_KEY")
ENCRYPT_SALT = os.environ.get("ENCRYPT_SALT")

# Email sending
MAIL_SERVER = "smtp.gmail.com"
Expand All @@ -33,17 +34,18 @@ class Config:
AWS_BUCKET_NAME = os.environ.get("AWS_BUCKET_NAME")
AWS_REGION = os.environ.get("AWS_REGION")

ENCRYPT_SALT = os.environ.get("ENCRYPT_SALT")

# Happiness export
UPLOAD_FOLDER = "./export/"

# Scheduled jobs
REDISCLOUD_URL = os.environ.get("REDISCLOUD_URL")

# Discord webhooks
AST_WEBHOOK_URL = os.environ.get("AST_WEBHOOK_URL")
BOIS_WEBHOOK_URL = os.environ.get("BOIS_WEBHOOK_URL")

WRAPPED_DATA_URL = os.environ.get("WRAPPED_DATA_URL")

class TestConfig:
TESTING = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///'
Expand Down

0 comments on commit 7ea8f12

Please sign in to comment.