Skip to content

Commit

Permalink
feat: improve getads lambda2
Browse files Browse the repository at this point in the history
  • Loading branch information
LIEN-YUHSIANG committed Oct 19, 2023
1 parent b4cdc33 commit 1e571c2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/lambda/get-ads/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,25 @@

@resp_handler
def get_imgs_list(board_id, ad_id):

results = []

# typeIII
if board_id and ad_id:
# Create the key and url when typeII api call
key = "/".join([board_id, ad_id])
bucket_name = bucket
ad_url = generate_url(bucket_name, key)
results = ad_url

# typeII
elif board_id:
response = table.query(KeyConditionExpression=Key(
"board_id").eq(board_id), ScanIndexForward=False)
results = response

# typeI
else:
response = table.scan(ConsistentRead=False)

if response:
results = response.get('Items', [])
elif ad_url:
results = ad_url
results = response

# response = table.scan()
# results = response.get('Items', [])
Expand Down

0 comments on commit 1e571c2

Please sign in to comment.