diff lookup.py @ 33:b82432594778

skaffold config and other updates
author drewp@bigasterisk.com
date Sat, 21 Aug 2021 14:24:57 -0700
parents c23acc88324b
children c7b59377ab35
line wrap: on
line diff
--- a/lookup.py	Sat Aug 21 14:24:09 2021 -0700
+++ b/lookup.py	Sat Aug 21 14:24:57 2021 -0700
@@ -10,6 +10,7 @@
 import datetime
 import json
 import logging
+import os
 import time
 import urllib.error
 import urllib.parse
@@ -25,8 +26,8 @@
 from link import Links, NotFound
 from pagetitle import PageTitle
 
-db = pymongo.Connection('mongodb.default.svc.cluster.local',
-                        tz_aware=True)['href']
+db = pymongo.MongoClient(os.environ['MONGODB_SERVICE_HOST'],
+                         tz_aware=True)['href']
 pageTitle = PageTitle(db)
 links = Links(db)
 renderer = Renderer(search_dirs=['template'], debug=bottle.DEBUG)
@@ -72,7 +73,7 @@
     those tags"""
     withTags = set(withTags)
     count = defaultdict(lambda: 0)  # tag : count
-    for doc in db['links'].find({'user': user}, fields=['extracted.tags']):
+    for doc in db['links'].find({'user': user}, projection=['extracted.tags']):
         docTags = set(doc.get('extracted', {}).get('tags', []))
         if withTags and not withTags.issubset(docTags):
             continue
@@ -243,4 +244,4 @@
 
 if __name__ == '__main__':
     logging.basicConfig(level=logging.INFO)
-    bottle.run(server='gunicorn', host='0.0.0.0', port=10002, workers=4)
+    bottle.run(server='gunicorn', host='0.0.0.0', port=10002, workers=1)