Skip to content

Commit

Permalink
fix: sync career was neglecting the image extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonNotJson committed Nov 11, 2023
1 parent 9b597b0 commit 442591e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lambda/sync-career/index.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from datetime import datetime
from utils import JsonPayloadBuilder
from utils import resp_handler, table, bucket, s3_client
from utils import resp_handler, table, bucket, s3_client, get_image_key


@resp_handler
Expand All @@ -15,12 +15,11 @@ def sync_career(key):
json_content = json.loads(file_content)

# Get folder (company name)
folder = key.split('/')[0] # Assuming the folder is the first part of the key
folder = key.split('/')[0]

# Construct keys for images
hero_image_key = f"{folder}/hero_image"
company_logo_key = f"{folder}/company_logo"

hero_image_key = get_image_key(folder, "hero_image")
company_logo_key = get_image_key(folder, "company_logo")

item = {
'job_id': json_content['job_id'],
Expand Down
8 changes: 8 additions & 0 deletions src/lambda/sync-career/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,11 @@ def handle(*args, **kwargs):
return api_response(500, resp)

return handle

def get_image_key(folder, image_name):
response = s3_client.list_objects_v2(Bucket=bucket, Prefix=f"{folder}/")
for obj in response.get('Contents', []):
key = obj['Key']
if key.startswith(f"{folder}/{image_name}"):
return key
return None

0 comments on commit 442591e

Please sign in to comment.