Skip to content

Commit

Permalink
add: load data from db in item api
Browse files Browse the repository at this point in the history
  • Loading branch information
machineCYC committed Nov 18, 2020
1 parent 1656393 commit 00133c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions api/tools/data_dict.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
TABLE_DICT = dict(
News="vwNews",
NewsPosition="NewsPosition",
Position="position",
Channel="channel",
Producer="producer",
)

DATABASE_DICT = dict(
News="JSON2",
NewsPosition="JSON2",
Position="JSON2",
Channel="JSON2",
Producer="JSON2",
)
10 changes: 2 additions & 8 deletions api/v1/endpoints/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@ def convert_lisdict2list(

@router.get("/item", response_model=ItemList)
async def get_data(request: Request, itemtype: ItemTypeInput):
convert_data = []
if itemtype == "Position":
convert_data = ["時代力量", "國民黨", "民進黨", "親民黨", "民眾黨", "無立場"]
elif itemtype == "Channel":
convert_data = ["新聞", "社群論壇", "聊天", "部落格", "內容農場", "影音"]
elif itemtype == "Producer":
raw_data = load.NID_items(dataset=itemtype)
convert_data = convert_lisdict2list(raw_data)
raw_data = load.NID_items(dataset=itemtype)
convert_data = convert_lisdict2list(raw_data)

logger.info(f"get itemtype:{itemtype} data")
return success_msg(convert_data)

0 comments on commit 00133c2

Please sign in to comment.