Skip to content

Commit

Permalink
feat: add mod flag (#312)
Browse files Browse the repository at this point in the history
* feat: adding mod flag to get all threads lambda

* feat: adding mod flag to board threads
  • Loading branch information
JasonNotJson authored Sep 6, 2023
1 parent e5a41f1 commit 6506067
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/lambda/get-all-threads/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@


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

response = table.scan()
items = response['Items']

for item in items:
item['mod'] = False
if 'uid' in item and item['uid'] == uid:
item['mod'] = True

body = JsonPayloadBuilder().add_status(
True).add_data(items).add_message('').compile()
return body


def handler(event, context):

return get_all_threads()
uid = ""

if "uid" in event["queryStringParameters"]:
uid = event["queryStringParameters"]["uid"]

return get_all_threads(uid)
9 changes: 8 additions & 1 deletion src/lambda/get-board-threads/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@


@resp_handler
def get_board_threads(board_id):
def get_board_threads(board_id, uid=''):

results = table.query(KeyConditionExpression=Key(
"board_id").eq(board_id), ScanIndexForward=False)["Items"]
if not results:
raise LookupError

for item in results:
item['mod'] = False
if 'uid' in item and item['uid'] == uid:
item['mod'] = True

body = JsonPayloadBuilder().add_status(
True).add_data(results).add_message('').compile()
return body
Expand All @@ -22,5 +27,7 @@ def handler(event, context):
params = {
"board_id": event["pathParameters"]["board_id"]
}
if "uid" in event["queryStringParameters"]:
params["uid"] = event["queryStringParameters"]["uid"]

return get_board_threads(**params)
4 changes: 3 additions & 1 deletion src/lambda/syllabus-scraper/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
"14-809(院生指導室)": "14-809",
"14-808(院生指導室)": "14-808",
"Seminar room 2 50-303": "50-303",
"drafting room": "57-1F"
"drafting room": "57-1F",
"-": "undecided",
"Faculty Office": "Faculty Office"
}

user_agents = [
Expand Down

0 comments on commit 6506067

Please sign in to comment.