codihuston / gairos

A time-keeper and scheduler for tasks
9 stars 2 forks source link

Add method of syncing userTaskHistory to google calendar #21

Closed codihuston closed 4 years ago

codihuston commented 4 years ago

Create the gql mutation update a google calendar event.

When displaying userTaskHistory, if eventId is null, show button to save this task history instance into google calendar? Or show the button always, to "update in google calendar"?

codihuston commented 4 years ago

If updating a userTaskHistory, and there IS NOT currently a google event id stored, and there is a startTime and endTime, write to google calendar, and update in gairos db.

If updating a userTaskHistory, and there IS currently a google event id stored, and there is a startTime and endTime, update to google calendar, and update in gairos db.

In the user interface, this same button will handle both cases above. That is, it will update in gairos db + google calendar. Since starting/stopping/then starting a task again should write two separate taskHistories to gairos / events to google (yet the UI can display total time additively), this update method will not be used in this case. Only when explicitly editing pre-existing history.

codihuston commented 4 years ago

In the final paragraph above will be true, then we can assume that when either creating a userTaskHistory, or updating a userTaskHistory, there will ALWAYS be a start+end time provided. Therefore, shouldn't we be able to assume that a googleEventId will always exist?

So, if when updating a userTaskHistory, and we attempt to update a google event, say either for some reason the googleEventId is null (it shouldn't be) or the provided googleEventId references a non-existing event. Under both cases, we should always ensure that a google event is written to the calendar.

codihuston commented 4 years ago

Tthe point of having endTime being optional with createMyTaskHistory() is that we can always ensure that the startTime of a task is persisted in case the client loses that information (cookies, etc.). This means that is possible that the googleEventId will be when updateMyTaskHistory() is invoked. In that case, since start+endTime are both required here, it is safe to create the google event. Should be able to apply the existing logic to create a google event out of a userTaskHistory here.

In the case that googleEventId exists, but was manually deleted from a google calendar, an exception "Not Found" will be thrown. This same error can occur if the calendar is not found as well, I believe?