From 6933a2dda7e82620cbb3d1bfc5b1c6ceb634c4b6 Mon Sep 17 00:00:00 2001 From: Yazan Armoush Date: Sun, 17 Dec 2023 18:59:44 -0500 Subject: [PATCH] Big Update --- backend/app.py | 5 +- backend/models/user.py | 19 +- backend/requirements.txt | 5 +- backend/routes/users.py | 8 +- .../utils/update_user_level_and_footprint.py | 167 +++++++++++++++++- backend/workers/jobs.py | 33 ++++ backend/workers/update_users.py | 41 +++++ frontend/assets/default_avatar.png | Bin 0 -> 15131 bytes frontend/assets/toSVG.tsx | 2 +- frontend/src/APIs/FLASK_API.tsx | 1 - frontend/src/widgets/profileWidget.tsx | 16 +- 11 files changed, 276 insertions(+), 21 deletions(-) create mode 100644 backend/workers/jobs.py create mode 100644 backend/workers/update_users.py create mode 100644 frontend/assets/default_avatar.png diff --git a/backend/app.py b/backend/app.py index 8d22eb0..02bb6f3 100644 --- a/backend/app.py +++ b/backend/app.py @@ -11,7 +11,7 @@ from routes.transportation import transportation_service from routes.food import food_service from routes.energy import energy_service - +from workers.jobs import start_jobs app = Flask(__name__) app.json = CustomJSONProvider(app) @@ -26,6 +26,9 @@ CORS(app) +start_jobs() + + @app.route("/") def home() -> Response: return jsonify('Carbon Track APP BACKEND API :: If You Can See This Message You Can Reach This API') diff --git a/backend/models/user.py b/backend/models/user.py index e8d6292..04f880e 100644 --- a/backend/models/user.py +++ b/backend/models/user.py @@ -20,6 +20,9 @@ class User(DB_MODEL): province: str household: int fuel_efficiency: float + monthly_emissions: int + yearly_emissions: int + overall_emissions: int def __init__( self, @@ -30,11 +33,14 @@ def __init__( badges: list[str], friends: list[str], monthly_score:int, - yearly_score:int, + yearly_score:int, overall_score:int, province: str, household: int, fuel_efficiency: float, + monthly_emissions: int, + yearly_emissions: int, + overall_emissions: int, ) -> None: super().__init__(oid) self.full_name = str(full_name) @@ -48,6 +54,9 @@ def __init__( self.province = province self.household = household self.fuel_efficiency = fuel_efficiency + self.monthly_emissions = monthly_emissions + self.yearly_emissions = yearly_emissions + self.overall_emissions = overall_emissions def to_json(self) -> json: return { @@ -62,7 +71,10 @@ def to_json(self) -> json: 'overall_score': self.overall_score, 'province': self.province, 'household': self.household, - 'fuel_efficiency': self.fuel_efficiency + 'fuel_efficiency': self.fuel_efficiency, + 'monthly_emissions': self.monthly_emissions, + 'yearly_emissions': self.yearly_emissions, + 'overall_emissions': self.overall_emissions, } @staticmethod @@ -80,6 +92,9 @@ def from_json(doc: json) -> User: province=doc["province"], household=doc["household"], fuel_efficiency=doc["fuel_efficiency"], + monthly_emissions=doc["monthly_emissions"], + yearly_emissions=doc["yearly_emissions"], + overall_emissions=doc["overall_emissions"] ) def __repr__(self) -> str: diff --git a/backend/requirements.txt b/backend/requirements.txt index 384a9c8..c88adcb 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,8 +1,9 @@ -firebase_admin==6.2.0 +firebase_admin==6.3.0 Flask==3.0.0 Flask_Cors==4.0.0 Flask_HTTPAuth==4.8.0 -pymongo==4.6.0 +pymongo==4.6.1 ruff==0.1.4 typing~=3.7.4.3 werkzeug~=3.0.1 +APScheduler~=3.10.4 diff --git a/backend/routes/users.py b/backend/routes/users.py index 81e1fdb..dabf0d3 100644 --- a/backend/routes/users.py +++ b/backend/routes/users.py @@ -40,7 +40,7 @@ def get_top_users() -> Response: user = { "rank": rank, "name": obj.full_name, - "footprint": 0, + "footprint": obj.monthly_emissions, "score": obj.overall_score, } rank += 1 @@ -57,7 +57,7 @@ def get_top_users() -> Response: user = { "rank": rank, "name": obj.full_name, - "footprint": 0, + "footprint": obj.yearly_emissions, "score": obj.overall_score, } rank += 1 @@ -74,7 +74,7 @@ def get_top_users() -> Response: user = { "rank": rank, "name": obj.full_name, - "footprint": 0, + "footprint": obj.overall_emissions, "score": obj.overall_score, } rank += 1 @@ -231,4 +231,4 @@ def update_user_name(user_id: str) -> Response: return jsonify({"user": item}), 200 except CarbonTrackError as e: - abort(code=400, description=f"{e}") \ No newline at end of file + abort(code=400, description=f"{e}") diff --git a/backend/utils/update_user_level_and_footprint.py b/backend/utils/update_user_level_and_footprint.py index 449bbd9..ae213f9 100644 --- a/backend/utils/update_user_level_and_footprint.py +++ b/backend/utils/update_user_level_and_footprint.py @@ -1,18 +1,181 @@ """ File Description """ +from datetime import datetime, timedelta + import ct_confiq from bson import ObjectId + +from models.energy import EnergyEntry +from models.food import FoodEntry from models.user import User +from models.transportation import TransportationEntry from mongodb_api.carbon_track_db import CarbonTrackDB +def _is_within_one_month(date_object): + # Get the current date + current_date = datetime.now() + + # Calculate the difference between the current date and the given date + difference = current_date - date_object + + # Check if the difference is less than or equal to 30 days + return difference <= timedelta(days=30) + + +def _is_within_one_year(date_object): + # Get the current date + current_date = datetime.now() + + # Calculate the difference between the current date and the given date + difference = current_date - date_object + + # Check if the difference is less than or equal to 30 days + return difference <= timedelta(days=365) + + def update_user_level_and_footprint(user_id: ObjectId) -> None: """ Docstring """ - user = User.from_json(CarbonTrackDB.users_coll.find_one({'_id': user_id})) - print(user.full_name) + weekly_entries_completed: int = 0 + decreased_emissions = 0 + user: User = User.from_json(CarbonTrackDB.users_coll.find_one({'_id': user_id})) + + overall_score = 0 + yearly_score = 0 + monthly_score = 0 + + # Get Filtered and Sorted Transportation Entries + transportation_entries_dicts: list[dict] = list(CarbonTrackDB.transportation_coll.find({'user_id': user.oid})) + transportation_entries: list[TransportationEntry] = [TransportationEntry.from_json(entry) for entry in transportation_entries_dicts] + transportation_entries = sorted(transportation_entries, key=lambda entry: entry.date) + transportation_entries_overall = [entry for entry in transportation_entries + if entry.calculate_carbon_emissions() != 0] + transportation_entries_yearly = [entry for entry in transportation_entries + if entry.calculate_carbon_emissions() != 0 and _is_within_one_year(entry.date)] + transportation_entries_monthly = [entry for entry in transportation_entries + if entry.calculate_carbon_emissions() != 0 and _is_within_one_month(entry.date)] + weekly_entries_completed += transportation_entries_overall.__len__() + if transportation_entries_overall.__len__() != 0: + last_entry = transportation_entries_overall[0] + for entry in transportation_entries_overall[1:]: + if last_entry.calculate_carbon_emissions() > entry.calculate_carbon_emissions(): + decreased_emissions += 1 + overall_score += 300 + overall_score += 100 + if entry in transportation_entries_yearly: + if last_entry.calculate_carbon_emissions() > entry.calculate_carbon_emissions(): + yearly_score += 300 + yearly_score += 100 + if entry in transportation_entries_monthly: + if last_entry.calculate_carbon_emissions() > entry.calculate_carbon_emissions(): + monthly_score += 300 + monthly_score += 100 + last_entry = entry + + overall_transportation_entries_emissions = sum([entry.calculate_carbon_emissions() for entry in transportation_entries_overall]) + yearly_transportation_entries_emissions = sum([entry.calculate_carbon_emissions() for entry in transportation_entries_yearly]) + monthly_transportation_entries_emissions = sum([entry.calculate_carbon_emissions() for entry in transportation_entries_monthly]) + + # Get Filtered and Sorted food Entries + food_entries_dicts: list[dict] = list(CarbonTrackDB.food_coll.find({'user_id': user.oid})) + food_entries: list[FoodEntry] = [FoodEntry.from_json(entry) for entry in food_entries_dicts] + food_entries = sorted(food_entries, key=lambda entry: entry.date) + food_entries_overall = [entry for entry in food_entries + if entry.calculate_carbon_emissions() != 0] + food_entries_yearly = [entry for entry in food_entries + if entry.calculate_carbon_emissions() != 0 and _is_within_one_year(entry.date)] + food_entries_monthly = [entry for entry in food_entries + if entry.calculate_carbon_emissions() != 0 and _is_within_one_month(entry.date)] + weekly_entries_completed += food_entries_overall.__len__() + if food_entries_overall.__len__() != 0: + last_entry = food_entries_overall[0] + for entry in food_entries_overall[1:]: + if last_entry.calculate_carbon_emissions() > entry.calculate_carbon_emissions(): + decreased_emissions += 1 + overall_score += 300 + overall_score += 100 + if entry in food_entries_yearly: + if last_entry.calculate_carbon_emissions() > entry.calculate_carbon_emissions(): + yearly_score += 300 + yearly_score += 100 + if entry in food_entries_monthly: + if last_entry.calculate_carbon_emissions() > entry.calculate_carbon_emissions(): + monthly_score += 300 + monthly_score += 100 + last_entry = entry + + overall_food_entries_emissions = sum([entry.calculate_carbon_emissions() for entry in food_entries_overall]) + yearly_food_entries_emissions = sum([entry.calculate_carbon_emissions() for entry in food_entries_yearly]) + monthly_food_entries_emissions = sum([entry.calculate_carbon_emissions() for entry in food_entries_monthly]) + + # Get Filtered and Sorted energy Entries + energy_entries_dicts: list[dict] = list(CarbonTrackDB.energy_coll.find({'user_id': user.oid})) + energy_entries: list[EnergyEntry] = [EnergyEntry.from_json(entry) for entry in energy_entries_dicts] + energy_entries = sorted(energy_entries, key=lambda entry: entry.date) + energy_entries_overall = [entry for entry in energy_entries + if entry.calculate_carbon_emissions() != 0] + energy_entries_yearly = [entry for entry in energy_entries + if entry.calculate_carbon_emissions() != 0 and _is_within_one_year(entry.date)] + energy_entries_monthly = [entry for entry in energy_entries + if entry.calculate_carbon_emissions() != 0 and _is_within_one_month(entry.date)] + weekly_entries_completed += energy_entries_overall.__len__() + if energy_entries_overall.__len__() != 0: + last_entry = energy_entries_overall[0] + for entry in energy_entries_overall[1:]: + if last_entry.calculate_carbon_emissions() > entry.calculate_carbon_emissions(): + decreased_emissions += 1 + overall_score += 300 + overall_score += 100 + if entry in energy_entries_yearly: + if last_entry.calculate_carbon_emissions() > entry.calculate_carbon_emissions(): + yearly_score += 300 + yearly_score += 100 + if entry in energy_entries_monthly: + if last_entry.calculate_carbon_emissions() > entry.calculate_carbon_emissions(): + monthly_score += 300 + monthly_score += 100 + last_entry = entry + + overall_energy_entries_emissions = sum([entry.calculate_carbon_emissions() for entry in energy_entries_overall]) + yearly_energy_entries_emissions = sum([entry.calculate_carbon_emissions() for entry in energy_entries_yearly]) + monthly_energy_entries_emissions = sum([entry.calculate_carbon_emissions() for entry in energy_entries_monthly]) + + # Calculate Badges + badges = [] + weekly_entries_completed = weekly_entries_completed // 3 + if weekly_entries_completed >= 1: + badges.append('completed_your_first_weekly_entry!') + if weekly_entries_completed >= 10: + badges.append('completed_10_weekly_entries!') + if weekly_entries_completed >= 50: + badges.append('completed_50_weekly_entries!') + if weekly_entries_completed >= 100: + badges.append('completed_100_weekly_entries!') + if decreased_emissions > 0: + badges.append('decreased_emissions_for_first_time!') + + # Combine Emissions + overall_carbon_emissions = overall_transportation_entries_emissions + overall_food_entries_emissions + overall_energy_entries_emissions + yearly_carbon_emissions = yearly_transportation_entries_emissions + yearly_food_entries_emissions + yearly_energy_entries_emissions + monthly_carbon_emissions = monthly_transportation_entries_emissions + monthly_food_entries_emissions + monthly_energy_entries_emissions + + # Update User + user.overall_emissions = int(overall_carbon_emissions) + user.yearly_emissions = int(yearly_carbon_emissions) + user.monthly_emissions = int(monthly_carbon_emissions) + user.overall_score = overall_score + user.yearly_score = yearly_score + user.monthly_score = monthly_score + user.badges = badges + CarbonTrackDB.users_coll.update_one( + {'_id': user.oid}, + {'$set': user.to_json()} + ) + # user_d = user.to_json() + # [print(f'{key}: {user_d[key]}') for key in user_d.keys()] if __name__ == '__main__': diff --git a/backend/workers/jobs.py b/backend/workers/jobs.py new file mode 100644 index 0000000..21055c9 --- /dev/null +++ b/backend/workers/jobs.py @@ -0,0 +1,33 @@ +""" +All Jobs will be container here +""" +from apscheduler.schedulers.background import BackgroundScheduler +from datetime import datetime +import ct_confiq + +# Jobs +from workers import update_users +ct_confiq.run_carbon_track_configurations() + + +def print_curr_time(): + # Put your function code here + print("Running my job at", datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + + +def start_jobs() -> None: + + # Create an instance of the scheduler + scheduler = BackgroundScheduler() + + # Add the job to the scheduler + scheduler.add_job(func=print_curr_time, trigger="interval", seconds=60) + scheduler.add_job(func=update_users.run_job, trigger="interval", seconds=60) + + # Start the scheduler + scheduler.start() + + +if __name__ == '__main__': + + start_jobs() diff --git a/backend/workers/update_users.py b/backend/workers/update_users.py new file mode 100644 index 0000000..379e028 --- /dev/null +++ b/backend/workers/update_users.py @@ -0,0 +1,41 @@ +""" +Validate all Logs Job +""" +from pprint import pprint + +from bson import ObjectId +import ct_confiq +from mongodb_api.carbon_track_db import CarbonTrackDB +from utils.update_user_level_and_footprint import update_user_level_and_footprint +ct_confiq.run_carbon_track_configurations() + + +def _update_users() -> None: + """ + Docstring {"processed": False} + """ + completed: int = 0 + users: list[dict[str, ObjectId]] = list(CarbonTrackDB.users_coll.find({}, {"_id": 1})) + if users.__len__() == 0: + return None + print("===================================================") + print(f"| Running 'update_users'") + print("===================================================") + print(f"| Completed {completed:<8}/{users.__len__():<8}| {100 * completed / users.__len__()}%") + + for user in users: + + update_user_level_and_footprint(user['_id']) + completed += 1 + print(f"| Completed {completed:<8}/{users.__len__():<8}| {100 * completed / users.__len__()}%") + + print("===================================================") + + +def run_job(): + _update_users() + + +if __name__ == '__main__': + _update_users() + diff --git a/frontend/assets/default_avatar.png b/frontend/assets/default_avatar.png new file mode 100644 index 0000000000000000000000000000000000000000..e397a40223f667931d4776c49ac5c9ac9b029fe6 GIT binary patch literal 15131 zcmYj&1yt1E6YpJ?Zj>KLBd8!Ch=4RK4N6K$cS|UpyC9{AloFBxA|aq4T`QrKgp|_V z-L<>#%m1D8&O01f_RgKTJ$LTRXI^P*s!)(Jk^%rI)KnFp0DuSmiwB4ap^rnq;dAJN z-A46^1^@wf06>KUa8-m_1;G100PB_jNTdQl?~zfjBLxu%tsko>0^HS4PSfWksD#8r z)yNY7vg=pBFz_Mc2E-DlrYNW9H@-DRlA%A6IlJfJA^NkHNuyxGYx9}wpKp?BX;| z*oa%75ii2}%42rEpU+gE``SjH2V(jUai4K4n4NXpor9TT3k96<=aAo-t}Rhj4-Nv? zXCx1V{=Piy&qr2Ar(q+pMo0aULX*rSEQ-|c5K6?j%@ZqC)7etVREqGWAduld!g zZJOm_2hIEFnE+Xxz&F@`N7*;8Rl1C17x5i9=puif*PbS9a|<)>^Gp#=lHkixhwtQ? zcAH<2ulx+q4Jx1hzVj;8y5Lb5({PHH=LCI?Xj0&)1W7%G_3=mb^wjygNBx8w)qh+I zCf-U$vlEAT1n0Vo&0khA(&19hQ!&xlc~>ThnkRBv`&0H$)sDvK^|?Okc~i3*3{m=y zvU$4Y+90U$}!Lw*MeS4W@DwwG{-% zx8Lv+D5eSHI_iTrRlnp4XD4pu`goEy*73)ppZ1I37R#6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G z_0f1|V!KJ(@Z~9_oks&xzULnq9m4fEMlHqzRL$t+|5R-r`TUyxe60%m|L0yR<7yO= ztMiY_KOr?RE*monIP>!pJ(4CjYo+=}IKFd-Cl=eBda)6bNBzY}`!Z&^T1l*|&azbN URCnk(WX1zEB~8ULdCRc>18shij{pDw literal 0 HcmV?d00001 diff --git a/frontend/assets/toSVG.tsx b/frontend/assets/toSVG.tsx index 36d77e2..dc51ae7 100644 --- a/frontend/assets/toSVG.tsx +++ b/frontend/assets/toSVG.tsx @@ -1,6 +1,6 @@ import React from 'react'; import Svg, { Path } from 'react-native-svg'; -import { GoogleSVGType } from '../src/components/types'; +import { type GoogleSVGType } from '../src/components/types'; diff --git a/frontend/src/APIs/FLASK_API.tsx b/frontend/src/APIs/FLASK_API.tsx index 9694b82..d07d462 100644 --- a/frontend/src/APIs/FLASK_API.tsx +++ b/frontend/src/APIs/FLASK_API.tsx @@ -27,7 +27,6 @@ const instance = axios.create({ instance.interceptors.request.use( async (config) => { const token = await getFirebaseAuthToken(); - console.log(token); if (token != null) { config.headers.Authorization = `Bearer ${token}`; diff --git a/frontend/src/widgets/profileWidget.tsx b/frontend/src/widgets/profileWidget.tsx index 9a87b59..9eb16dc 100644 --- a/frontend/src/widgets/profileWidget.tsx +++ b/frontend/src/widgets/profileWidget.tsx @@ -13,12 +13,14 @@ const ProfileWidgetBox: React.FC = ({ user }) => { Josefin: require('../../assets/fonts/JosefinSansThinRegular.ttf'), }); - const [profilePicture, setProfilePicture] = useState(null); + const [profilePicture, setProfilePicture] = useState('https://cianmaggs.github.io/google-homepage/images/loginbutton.png'); const fetchProfilePicture = useCallback(async () => { try { const picture = await firebaseService.getProfilePicture(); - setProfilePicture(picture); + if (picture != null) { + setProfilePicture(picture); + } } catch (error) { console.error('Error fetching profile picture:', error); } @@ -30,18 +32,16 @@ const ProfileWidgetBox: React.FC = ({ user }) => { }, [fetchProfilePicture]) ); - if (!loaded) { - return <>; - } - - if (!loaded) { return <>; } return ( - + {user.full_name}