Only apply recent changes.

New users and password changes should be applied, but updaging
all users all the time would waste processing.
This commit is contained in:
Rasmus Kaj 2025-02-23 21:37:33 +01:00
parent e2edf809cb
commit 30e7d74bab

11
poll.py
View file

@ -1,4 +1,5 @@
#! /bin/env python3
from datetime import datetime, timezone, timedelta
from requests import get, post, patch
from os import getenv
import logging
@ -9,9 +10,15 @@ fingerpass = getenv('FINGER_PW')
gitauth = (getenv('GIT_USER'), getenv('GIT_PW'))
fingerurl = f'https://finger.stacken.kth.se/services/git/all'
response = get(fingerurl, auth=('git', fingerpass))
fingerurl = f'https://finger.stacken.kth.se/services/git/all'
query = {}
if True:
since = datetime.now(timezone.utc) - timedelta(minutes=30)
query['since'] = since.strftime("%Y-%m-%dT%T%Z")
response = get(fingerurl, params=query, auth=('git', fingerpass))
response.raise_for_status()
for (user, passwd) in response.json().items():