]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/cron_banip.py
make maxmimum bulks configurable
[nominatim.git] / utils / cron_banip.py
index b5944a215789b0ab3f13f8490389ad5b853c0225..ad32b852f5159fdca5f3f4b7620434abadd5d01b 100755 (executable)
@@ -65,6 +65,7 @@ BLOCK_LOWER=4000
 BLOCK_LOADFAC=380
 BULK_LOADFAC=160
 BULK_LOWER=1500
+MAX_BULK_IPS=85
 
 #
 # END OF DEFAULT SETTINGS
@@ -108,19 +109,19 @@ dbload = int(cur.fetchone()[0])
 
 BLOCK_LIMIT = max(BLOCK_LOWER, BLOCK_UPPER - BLOCK_LOADFAC * (dbload - 75))
 BULKLONG_LIMIT = max(BULK_LOWER, BULKLONG_LIMIT - BULK_LOADFAC * (avgload - 14))
-if len(prevbulks) > 85:
-    BLOCK_LIMIT = max(3600, BLOCK_LOWER - (len(prevbulks) - 85)*10)
+if len(prevbulks) > MAX_BULK_IPS:
+    BLOCK_LIMIT = max(3600, BLOCK_LOWER - (len(prevbulks) - MAX_BULK_IPS)*10)
 
 # get the new block candidates
 cur.execute("""
   SELECT ipaddress, max(count) FROM
    ((SELECT * FROM
-     (SELECT ipaddress, sum(case when endtime is null then 1 else 1+date_part('epoch',endtime-starttime) end) as count FROM new_query_log
+     (SELECT ipaddress, sum(case when endtime is null then 1 else 1+1.5*date_part('epoch',endtime-starttime) end) as count FROM new_query_log
       WHERE starttime > now() - interval '1 hour' GROUP BY ipaddress) as i
    WHERE count > %s)
    UNION
    (SELECT ipaddress, count * 3 FROM
-     (SELECT ipaddress, sum(case when endtime is null then 1 else 1+date_part('epoch',endtime-starttime) end) as count FROM new_query_log 
+     (SELECT ipaddress, sum(case when endtime is null then 1 else 1+1.5*date_part('epoch',endtime-starttime) end) as count FROM new_query_log 
       WHERE starttime > now() - interval '10 min' GROUP BY ipaddress) as i
    WHERE count > %s)) as o
   GROUP BY ipaddress