Skip to content

Commit

Permalink
fix: fixing multiple lambda functions (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonNotJson authored Apr 27, 2023
1 parent bd3eb70 commit a91ffeb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/lambda/get-all-threads/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

@resp_handler
def get_all_threads():
# respons will be table scan by TableName and return first 50 items

response = table.scan(TableName=table)
response = table.scan(TableName=table, Limit=50)
items = response['Items']

body = JsonPayloadBuilder().add_status(
Expand Down
5 changes: 4 additions & 1 deletion src/lambda/get-single-thread/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def get_single_thread(board_id, ts, thread_id, uid):
"created_at": ts,
},
ConditionExpression=Attr('thread_id').eq(thread_id),
UpdateExpression="SET views = views + :incr",
UpdateExpression="SET #v = #v + :incr",
ExpressionAttributeNames={
'#v': 'views'
},
ExpressionAttributeValues={
":incr": 1
}
Expand Down
7 changes: 4 additions & 3 deletions src/lambda/patch-thread/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@


@resp_handler
def patch_thread(board_id, ts, thread_id, thread):
def patch_thread(board_id, ts, uid, thread_id, thread):

dt_now = datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
table.update_item(
Key={
"board_id": board_id,
"created_at": ts,
},
ConditionExpression=Attr('thread_id').eq(thread_id),
ConditionExpression=Attr('thread_id').eq(
thread_id) & Attr('uid').eq(uid),
UpdateExpression='SET body = :tbody, title = :ttitle, update_at = :ts',
ExpressionAtrributeValues={
ExpressionAttributeValues={
":tbody": [thread['body']],
":ttitle": [thread['title']],
":ts": dt_now
Expand Down
2 changes: 1 addition & 1 deletion src/lambda/post-thread/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def post_thread(board_id, thread, uid):
"tag_id": thread["tag_id"],
"group_id": thread["group_id"],
"univ_id": thread["univ_id"],
"view": 0,
"views": 0,
}

table.put_item(Item=thread_item)
Expand Down

0 comments on commit a91ffeb

Please sign in to comment.