CruGlobal/mpdx — pull request #169 by draffensperger (2014-11-03 23:01:37+00:00)
Title: Google contacts sync fixes

Fixes to bugs I found while testing the Google contacts sync:
- Associate Google contacts with a contact and person not just a contact (both remotely and stored as links to MPDX records in the `google_contacts` table). This was necessary because people can be in multiple contacts, mostly due to duplicate data and my previous method of associating people directly with Google contacts was that it caused multiple contact-people to map to the same Google contacts which would cause errors and collided data.
- Added logic to delete the Google contacts associated with the "losers" in a contact or person merge
- Turned off validations for the contact.save which is similar to the Tnt import. It could import invalid-for-MPDX data from Google, but the user will get an invalid data message when they try to save that contact, and they'll be prompted to fix it then.
- Fixed bugs in the way that I compared normalized emails and phone numbers for the sync
- I made a slight optimization to how query for figuring out which contacts to sync works. It now compares each remotely updated Google contact with its own last sync time rather than the overall last sync time, which will allow us to catch a user-changed Google contact during a sync, but also avoid syncing Google contacts that were changed by the sync itself.