-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: renamed forum database and fixed multiple api (#230)
* feat: updated api get schema and renamed database * fix: fix lambda function * fix: fixed lambda get single thread and others
- Loading branch information
1 parent
d7e82e0
commit 6620d99
Showing
9 changed files
with
57 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def handler(event, context): | ||
pass |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,36 @@ | ||
# from boto3.dynamodb.conditions import Key | ||
# from datetime import datetime | ||
# from utils import JsonPayloadBuilder, table, resp_handler | ||
from boto3.dynamodb.conditions import Key | ||
from datetime import datetime | ||
from utils import JsonPayloadBuilder, table, resp_handler | ||
|
||
|
||
# @resp_handler | ||
# def get_thread(thread_id): | ||
# now = datetime.now() | ||
@resp_handler | ||
def get_single_thread(thread_id): | ||
|
||
# items = table.query( | ||
# KeyConditionExpression='sort_key <= :sk', | ||
# ExpressionAttributeValues={ | ||
# ':sk': now.strftime('%Y-%m-%d %H:%M:%S') | ||
# }, | ||
# ScanIndexForward=False, | ||
# Limit=50 | ||
# ) | ||
results = table.query(KeyConditionExpression=Key( | ||
"thread_id").eq(thread_id))["Items"] | ||
if not results: | ||
raise LookupError | ||
|
||
# body = JsonPayloadBuilder().add_status( | ||
# True).add_data(items).add_message('').compile() | ||
# return body | ||
table.update_item( | ||
key={ | ||
"thread_id": thread_id | ||
}, | ||
UpdateExpression="SET views = views + :incr", | ||
ExpressionAttributeValues={ | ||
":incr": 1 | ||
} | ||
) | ||
|
||
item = results[0] | ||
|
||
# def handler(event, context): | ||
# params = { | ||
# "thread_id": event["queryStringParameters"]["id"] | ||
# } | ||
body = JsonPayloadBuilder().add_status( | ||
True).add_data(item).add_message('').compile() | ||
return body | ||
|
||
# return get_thread(**params) | ||
|
||
def handler(event, context): | ||
params = { | ||
"thread_id": event["pathParameters"]["thread_id"] | ||
} | ||
|
||
return get_single_thread(**params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
# from boto3.dynamodb.conditions import Key | ||
# import boto3 | ||
# from datetime import datetime | ||
# from utils import JsonPayloadBuilder, table, resp_handler | ||
from boto3.dynamodb.conditions import Key | ||
import boto3 | ||
from datetime import datetime | ||
from utils import JsonPayloadBuilder, table, resp_handler | ||
|
||
|
||
# @resp_handler | ||
# def get_threads(): | ||
@resp_handler | ||
def get_threads(): | ||
|
||
# response = table.scan(TableName=table) | ||
# items = response['Items'] | ||
response = table.scan(TableName=table) | ||
items = response['Items'] | ||
|
||
# body = JsonPayloadBuilder().add_status( | ||
# True).add_data(items).add_message('').compile() | ||
# return body | ||
body = JsonPayloadBuilder().add_status( | ||
True).add_data(items).add_message('').compile() | ||
return body | ||
|
||
|
||
# def handler(event, context): | ||
def handler(event, context): | ||
|
||
# return get_threads() | ||
return get_threads() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def handler(event, context): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters