BULKSHORT_LIMIT=2000
BLOCK_UPPER=19000
BLOCK_LOADFAC=300
+BULK_LOADFAC=100
#
# END OF DEFAULT SETTINGS
avgload = int(float(fd.readline().split()[1]))
fd.close()
-BLOCK_LIMIT = BLOCK_UPPER - BLOCK_LOADFAC * avgload
-
# read the previous blocklist
WHITELIST = set(WHITELIST.split()) if WHITELIST else set()
prevblocks = []
except IOError:
pass #ignore non-existing file
+# current number of bulks
+numbulks = len(prevbulks)
+
+BLOCK_LIMIT = BLOCK_UPPER - BLOCK_LOADFAC * (numbulks - 30)
+BULKLONG_LIMIT = BULKLONG_LIMIT - BULK_LOADFAC * (avgload - 16)
+
conn = psycopg2.connect('dbname=nominatim')
cur = conn.cursor()
cur.execute("""
SELECT DISTINCT ipaddress FROM new_query_log
WHERE ipaddress IN ('%s') AND starttime > now() - interval '%s'
+ AND starttime > date_trunc('day', now())
""" % ("','".join(debulkcandidates), BULKCOOLOFF_PERIOD))
for c in cur: