Skip to content

Commit

Permalink
Merge pull request #226 from computas/SP24-admin-bug-fix
Browse files Browse the repository at this point in the history
Sp24 admin bug fix
  • Loading branch information
Ivan-Computas authored Oct 16, 2024
2 parents 6d2208c + b1a50aa commit 183f98f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/admin/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def authenticate():
@admin.route("/admin/getStatisticsPerMonth", methods=["GET"])
def monthly_statistics():
is_authenticated()
month = request.args.get('month')
year = request.args.get('year')
month = request.args.get("month")
year = request.args.get("year")
amount = shared_models.get_games_played_per_month(month, year)

return json.dumps(amount), 200
Expand All @@ -56,7 +56,7 @@ def monthly_statistics():
def yearly_statistics():
is_authenticated()

year = request.args.get('year')
year = request.args.get("year")
amount = shared_models.get_games_played_per_year(year)

return json.dumps(amount), 200
Expand Down Expand Up @@ -93,7 +93,7 @@ def get_count_per_month():
"""
try:
is_authenticated()
year = request.args.get('year')
year = request.args.get("year")
year = int(year)
count_list = shared_models.get_scores_count_per_month(year)

Expand Down Expand Up @@ -141,7 +141,10 @@ def admin_page(action):
"BLOB_image_count": new_blob_image_count,
}
except Exception as e:
current_app.logger.error("Something in admin/status failed: " + str(e))
current_app.logger.error(
"Something in admin/status failed: " + str(e)
)
return json.dumps(e), 500
return json.dumps(data), 200

elif action == "logging":
Expand Down
18 changes: 17 additions & 1 deletion src/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def create_container():
raise Exception("Could not create container")


def image_count():
def image_count_old():
"""
Returns number of images in relevant container.
"""
Expand All @@ -100,6 +100,22 @@ def image_count():
return container_client.get_container_properties().metadata["image_count"]


def image_count():
blob_service_client = BlobServiceClient.from_connection_string(
Keys.get("BLOB_CONNECTION_STRING")
)
container_client = blob_service_client.get_container_client(
Keys.get("CONTAINER_NAME")
)

# Initialize the counter for all files
file_count = 0

# Iterate over all the blobs in the container
file_count = sum(1 for _ in container_client.list_blobs())
return file_count


def blob_connection(container_name):
"""
Helper method for connection to blob service.
Expand Down

0 comments on commit 183f98f

Please sign in to comment.