|
|
@ -35,13 +35,13 @@ MSG_PWNED_PASSWORD = events.FlashMessage.warning( |
|
|
|
def find_consumables(repo, repeat=3, days=365 * 2): |
|
|
|
def find_consumables(repo, repeat=3, days=365 * 2): |
|
|
|
""" search for orders that are requested often """ |
|
|
|
""" search for orders that are requested often """ |
|
|
|
unsorted = _find_consumables(repo, repeat, days) |
|
|
|
unsorted = _find_consumables(repo, repeat, days) |
|
|
|
return sorted(unsorted, key=lambda x: x.cas_description) |
|
|
|
return sorted(unsorted, key=lambda o: o.cas_description) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _find_consumables(repo, repeat=3, days=365 * 2): |
|
|
|
def _find_consumables(repo, repeat=3, days=365 * 2): |
|
|
|
""" helper function for find_consumables() implementation """ |
|
|
|
""" helper function for find_consumables() implementation """ |
|
|
|
limit_date = datetime.now() - timedelta(days=days) |
|
|
|
limit_date = datetime.utcnow() - timedelta(days=days) |
|
|
|
relevant = repo.list_consumables(limit_date, CONSUMABLE_STATI) |
|
|
|
relevant = repo.list_consumable_candidates(limit_date, CONSUMABLE_STATI) |
|
|
|
counter = {} |
|
|
|
counter = {} |
|
|
|
for order in relevant: |
|
|
|
for order in relevant: |
|
|
|
item = counter.setdefault( |
|
|
|
item = counter.setdefault( |
|
|
|