sync-cut: add argument to control synchronisation delta

This commit is contained in:
Frédéric Péters 2020-09-08 13:12:37 +02:00
parent de7997f1b1
commit fab734b7e0
1 changed files with 7 additions and 1 deletions

View File

@ -27,8 +27,14 @@ from authentic2_auth_oidc.models import OIDCProvider, OIDCAccount
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--delta', metavar='DELTA', type=int, default=300)
def handle(self, *args, **options):
verbose = int(options['verbosity']) > 0
delta = options['delta']
# check all existing users
def chunks(l, n):
@ -56,7 +62,7 @@ class Command(BaseCommand):
# update recently modified users
url = settings.CUT_API_BASE_URL + 'users/?modified__gt=%s' % (
datetime.datetime.now() - datetime.timedelta(seconds=300)).strftime('%Y-%m-%dT%H:%M:%S')
datetime.datetime.now() - datetime.timedelta(seconds=delta)).strftime('%Y-%m-%dT%H:%M:%S')
resp = requests.get(url, auth=settings.CUT_API_CREDENTIALS)
resp.raise_for_status()
for user_dict in resp.json()['results']: