-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
276 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.