|
@@ -13,7 +13,7 @@ from netaddr import IPAddress
|
|
from netaddr.strategy.ipv4 import packed_to_int as unpack_v4
|
|
from netaddr.strategy.ipv4 import packed_to_int as unpack_v4
|
|
from netaddr.strategy.ipv6 import packed_to_int as unpack_v6
|
|
from netaddr.strategy.ipv6 import packed_to_int as unpack_v6
|
|
import socket
|
|
import socket
|
|
-from datetime import datetime
|
|
|
|
|
|
+from datetime import datetime, timedelta
|
|
from uuid import uuid4
|
|
from uuid import uuid4
|
|
|
|
|
|
app = Flask(__name__)
|
|
app = Flask(__name__)
|
|
@@ -168,7 +168,13 @@ def get_targets(uuid):
|
|
# participant.
|
|
# participant.
|
|
already_done = Target.query.join(handled_targets).filter_by(participant_id=participant.id).with_entities(Target.id)
|
|
already_done = Target.query.join(handled_targets).filter_by(participant_id=participant.id).with_entities(Target.id)
|
|
# This takes the negation of the previous set.
|
|
# This takes the negation of the previous set.
|
|
- return Target.query.filter(~Target.id.in_(already_done))
|
|
|
|
|
|
+ new_tasks = Target.query.filter(~Target.id.in_(already_done))
|
|
|
|
+ max_age = app.config.get('MAX_AGE', 0)
|
|
|
|
+ if max_age == 0:
|
|
|
|
+ return new_tasks
|
|
|
|
+ else:
|
|
|
|
+ limit = datetime.now() - timedelta(seconds=max_age)
|
|
|
|
+ return new_tasks.filter(Target.submitted >= limit)
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
@app.route('/')
|