alan-turing-institute / WimbledonPlanner

Project planning for REG
MIT License
0 stars 0 forks source link

Unique Name Error if Harvest & Forecast Accounts Not Linked #71

Open jack89roberts opened 4 years ago

jack89roberts commented 4 years ago

Was getting this error:

~/GitHub/WimbledonPlanner/wimbledon/wimbledon.py in get_person_id(self, name)
    202 
    203         if len(person_id) != 1:
--> 204             raise ValueError('Could not unique person with name ' + name)
    205 
    206         return person_id.index[0]

ValueError: Could not unique person with name Matthew Carver

Wimbledon merges Harvest & Forecast users by Harvest ID. If the Harvest ID isn't present for a Forecast user it's created as a distinct user without any other checks. This means you can end up with two users with the same name in the Wimbledon database if accounts are separately created on Harvest & Forecast without linking them. If two users have the same name get_person_id(name) raises the error above as it doesn't know which to pick. Could add a name check to the database updating script to help this.

In the meantime, here's how to link Harvest & Forecast accounts: https://help.getharvest.com/forecast/harvest-and-forecast/faqs/link-people-harvest-and-forecast/ The preferred approach is to create the user on Harvest, and then import the Harvest user to Forecast afterwards. If the Forecast and Harvest users have been created separately, you can import the Harvest user (in Forecast) to create the link as long as they both share the same name and email address.