forked from KPF-newstrust/ntrust-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler_score.py
More file actions
35 lines (26 loc) · 1.22 KB
/
Copy pathhandler_score.py
File metadata and controls
35 lines (26 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import datetime
import configparser
import helper.mongo
from ntrust import jnscore
def process_score_all(ver, param):
news_id = param["newsId"]
coll = helper.mongo.get_collection("news")
coll_stat = helper.mongo.get_collection("asStats")
doc = coll.find_one({"newsId":news_id})
if not doc:
raise RuntimeError("NotFound by newsId:" + news_id)
category = doc["categoryFinal"]
mediaType = "방송" if doc["mediaName"] in jnscore.BROADCASTS else "신문"
jsco = jnscore.evaluate(category, mediaType, doc)
coll.update_one({"newsId": news_id}, {"$set":{"score":jsco.scores}, "$unset":{"score_byline":""}}, upsert=False)
#print(score_sets)
coll_stat.update_one({"news_id": news_id}, {"$set":{"title": doc["title"], "score_totalSum": jsco.scores["totalSum"],
"insertDt":doc["insertDt"],
"journal": jsco.journal, "journal_totalSum": jsco.journalSum,
"vanilla": jsco.vanilla, "vanilla_totalSum": jsco.vanillaSum
}, "$unset":{"pubDate":""}}, upsert=False)
print("Score updated: %s => %s" % (doc["title"], jsco.journalSum))
if __name__ == "__main__":
print("yes, main")
helper.mongo.connect()
process_score_all(0, {"newsId":"01100101.20160601061030422"})