Closed OriHoch closed 6 years ago
@OriHoch I can't run it in production since you removed the scraping, can you scroll up and paste the exception you got?
@alonisser I neglected to copy the error
The problem is that you are saving the member id in the speaker_id, but the speaker_id is defined as relation to persons, not members
ProtocolPart model
speaker = models.ForeignKey('persons.Person', blank=True, null=True, related_name='protocol_parts')
I guess you might miss this error if you happen to have the same member_id as an existing person_id (but it might be a different person)
Here are steps to reproduce the same error (on production DB):
./manage.py shell_plus
part = ProtocolPart.objects.get(pk=6268439)
mk = Member.objects.get(pk=924)
person = Person.objects.get(mk=mk)
part.speaker_id = mk.id
part.save()
IntegrityError: insert or update on table "committees_protocolpart" violates foreign key constraint "speaker_id_refs_id_6023887a"
DETAIL: Key (speaker_id)=(924) is not present in table "persons_person".
part.speaker_id = person.id
part.save()
LOL I can swear then used to be logic to enforce having the same id, somewhere in the listener creating persons. THE REAL PROBLEM IS THAT NOW I CANT FIND ANY OF THE PERSON CREATING LOGIC. Any ideas where it disappeared
Ok, found it. Hate the Damm Django signals antipattern , can be hidden anywhere
thanks, added to draft release v1.0.7
need to publish this draft release (after some testing maybe..) and update it in open knesset (let me know if you want me to do it)
Hmm. I actually added it to 1.0.6 and released it.. :( I tested it on my machine and looked legit
right, sorry.. missed it
Reproduction
ubuntu@ip-10-209-139-40:~$./oknesset_manage.sh download_knesset_datapackage --scrape --url=https://s3.amazonaws.com/knesset-data/datapackage_last_120_days_2017-07-07.zip
expected
actual