Skip to content

Commit

Permalink
fix: data path
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Dec 31, 2024
1 parent 20e0bfd commit 1fbb0dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 2 additions & 3 deletions codeforlife/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ..types import JsonDict
from .custom import ENV, SERVICE_BASE_DIR, SERVICE_BASE_URL, SERVICE_NAME
from .otp import AWS_S3_APP_BUCKET, AWS_S3_APP_FOLDER
from .otp import AWS_S3_APP_BUCKET, DB_DATA_PATH

if t.TYPE_CHECKING:
from mypy_boto3_s3.client import S3Client
Expand Down Expand Up @@ -50,8 +50,7 @@ def get_databases():
# Get the dbdata object.
s3: "S3Client" = boto3.client("s3")
db_data_object = s3.get_object(
Bucket=t.cast(str, AWS_S3_APP_BUCKET),
Key=f"{AWS_S3_APP_FOLDER}/dbMetadata/codeforlife/db.dbdata",
Bucket=t.cast(str, AWS_S3_APP_BUCKET), Key=DB_DATA_PATH
)

# Load the object as a JSON dict.
Expand Down
13 changes: 13 additions & 0 deletions codeforlife/settings/otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,22 @@
import os

# App configuration.

APP_ID = os.getenv("APP_ID")
APP_VERSION = os.getenv("APP_VERSION")

# AWS S3 configuration.

AWS_S3_APP_BUCKET = os.getenv("aws_s3_app_bucket")
AWS_S3_APP_FOLDER = os.getenv("aws_s3_app_folder")

# Database configuration.

DB_NAME = os.getenv("DB_NAME")
DB_SCHEMA_NAME = os.getenv("DB_SCHEMA_NAME")
DB_INSTANCE_NAME = os.getenv("DB_INSTANCE_NAME")
DB_DATA_PATH = (
f"{AWS_S3_APP_FOLDER}/dbMetadata/"
+ (f"{DB_INSTANCE_NAME}/" if DB_INSTANCE_NAME else "")
+ f"{DB_NAME}/{DB_SCHEMA_NAME}.dbdata"
)

0 comments on commit 1fbb0dc

Please sign in to comment.