|
@@ -11,6 +11,7 @@ from time import strftime,time
|
|
|
|
|
|
|
|
from multiprocessing import Pool
|
|
from multiprocessing import Pool
|
|
|
import sys
|
|
import sys
|
|
|
|
|
+from analytics import post
|
|
|
|
|
|
|
|
|
|
|
|
|
def parseSource(s):
|
|
def parseSource(s):
|
|
@@ -106,6 +107,8 @@ def news_worker(source, kw, d, q):
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO influx start
|
|
# TODO influx start
|
|
|
|
|
+
|
|
|
|
|
+post('start', {}, 1)
|
|
|
start = time()
|
|
start = time()
|
|
|
sources = db().sources()
|
|
sources = db().sources()
|
|
|
db().purge_error()
|
|
db().purge_error()
|
|
@@ -113,6 +116,11 @@ pool = Pool(processes=4)
|
|
|
ret = pool.map(parseSource, sources)
|
|
ret = pool.map(parseSource, sources)
|
|
|
new = sum([r[3] for r in ret])
|
|
new = sum([r[3] for r in ret])
|
|
|
tot = sum([r[1] for r in ret])
|
|
tot = sum([r[1] for r in ret])
|
|
|
|
|
+
|
|
|
|
|
+post('new', {}, new)
|
|
|
|
|
+post('total', {}, tot)
|
|
|
|
|
+# TODO influx source new
|
|
|
|
|
+# TODO influx source total
|
|
|
# n = sum(ret)
|
|
# n = sum(ret)
|
|
|
# sret = sorted(ret, key=lambda tup: tup[0])
|
|
# sret = sorted(ret, key=lambda tup: tup[0])
|
|
|
# print(sret)
|
|
# print(sret)
|
|
@@ -121,3 +129,4 @@ print("[%s] %d/%d new articles, total time %d sec" %
|
|
|
(strftime("%H:%M:%S"), new, tot, time()-start))
|
|
(strftime("%H:%M:%S"), new, tot, time()-start))
|
|
|
print("#" * 75)
|
|
print("#" * 75)
|
|
|
# TODO influx end
|
|
# TODO influx end
|
|
|
|
|
+post('start', {}, 0)
|