Browse Source

Fix bug in mismatch between IDs

Maarten van den Berg 5 years ago
parent
commit
abd3266d2a
1 changed files with 7 additions and 7 deletions
  1. 7 7
      piket_server/aardbei_sync.py

+ 7 - 7
piket_server/aardbei_sync.py

453
 
453
 
454
     for member in aardbei_members:
454
     for member in aardbei_members:
455
         p: Optional[Person] = Person.query.filter_by(
455
         p: Optional[Person] = Person.query.filter_by(
456
-            aardbei_id=member.aardbei_id
456
+            aardbei_id=member.person.aardbei_id
457
         ).one_or_none()
457
         ).one_or_none()
458
 
458
 
459
         if p is not None:
459
         if p is not None:
492
     """
492
     """
493
 
493
 
494
     for match in matches:
494
     for match in matches:
495
-        match.local.aardbei_id = match.remote.aardbei_id
495
+        match.local.aardbei_id = match.remote.person.aardbei_id
496
         match.local.display_name = match.remote.display_name
496
         match.local.display_name = match.remote.display_name
497
         logging.info(
497
         logging.info(
498
             "Linking local %s (%s) to remote %s (%s)",
498
             "Linking local %s (%s) to remote %s (%s)",
499
             match.local.full_name,
499
             match.local.full_name,
500
             match.local.person_id,
500
             match.local.person_id,
501
             match.remote.display_name,
501
             match.remote.display_name,
502
-            match.remote.aardbei_id,
502
+            match.remote.person.aardbei_id,
503
         )
503
         )
504
 
504
 
505
         db.session.add(match.local)
505
         db.session.add(match.local)
516
         pnew = Person(
516
         pnew = Person(
517
             full_name=member.person.full_name,
517
             full_name=member.person.full_name,
518
             display_name=member.display_name,
518
             display_name=member.display_name,
519
-            aardbei_id=member.aardbei_id,
519
+            aardbei_id=member.person.aardbei_id,
520
             active=False,
520
             active=False,
521
         )
521
         )
522
         logging.info(
522
         logging.info(
523
             "Creating new person for %s / %s (%s)",
523
             "Creating new person for %s / %s (%s)",
524
             member.person.full_name,
524
             member.person.full_name,
525
             member.display_name,
525
             member.display_name,
526
-            member.aardbei_id,
526
+            member.person.aardbei_id,
527
         )
527
         )
528
         db.session.add(pnew)
528
         db.session.add(pnew)
529
 
529
 
603
         for item in resp.json():
603
         for item in resp.json():
604
             result.append(SparseAardbeiActivity.from_aardbei_dict(item))
604
             result.append(SparseAardbeiActivity.from_aardbei_dict(item))
605
 
605
 
606
-    now = datetime.datetime.now()
606
+    now = datetime.datetime.now(datetime.timezone.utc)
607
     result.sort(key=lambda x: SparseAardbeiActivity.distance(x, now))
607
     result.sort(key=lambda x: SparseAardbeiActivity.distance(x, now))
608
     return result
608
     return result
609
 
609
 
640
     activity as active, and all other people as inactive.
640
     activity as active, and all other people as inactive.
641
     """
641
     """
642
     ps = activity.participants
642
     ps = activity.participants
643
-    pids: List[PersonId] = [p.person.aardbei_id for p in ps]
643
+    pids: List[PersonId] = [p.person.aardbei_id for p in ps if p.attending]
644
 
644
 
645
     Person.query.update(values={"active": False})
645
     Person.query.update(values={"active": False})
646
     Person.query.filter(Person.aardbei_id.in_(pids)).update(
646
     Person.query.filter(Person.aardbei_id.in_(pids)).update(