wizonesolutions / habitrpg-todo-sync

HabitRPG Todo Synchronization
22 stars 3 forks source link

Actual todo synchronization #1

Closed wizonesolutions closed 11 years ago

wizonesolutions commented 11 years ago

Now I've got authentication working for both APIs and can pull tasks from Habit.

Copy-pasting the plan I typed to myself on IRC:

[16:44:45] <wizonesolutions> RTM AUTHENTICATION WORKING wooooooo
[16:45:05] <wizonesolutions> now some client work, then hopefully I can get a really basic sync working
[16:45:31] <wizonesolutions> goal 1 is just to add all tasks to Habit that don't already exist and don't even parse the Habit todos yet.
[16:45:48] <wizonesolutions> then add in some logic to not double-add
[16:46:05] <wizonesolutions> then logic to delete ones deleted on the RTM side
[16:46:42] <wizonesolutions> and finally to complete ones completed in Habit on the RTM side. but probably all based on the RTM states. e.g. I will simply see that in Habit it's done but it isn't done in RTM and assume that I should mark it complete in RTM
[16:46:48] <wizonesolutions> that way I don't have to cache the state of Habit todos

Elaborating on this, I think goal 1 is actually just to add all tasks to Habit wholesale. Don't even compare. Goal 2 is to compare and not double-add, and so on. So all_goals++;

I am psyched.

wizonesolutions commented 11 years ago

Goal 1 achieved.

Next goal is to now not add tasks that already exist.

@lefnire said that the ability to add arbitrary properties via the API would be around for a bit, so I'm just going to do that. Something like last_sync (ISO-8601 timestamp, courtesy of Moment), from_api (rtm), remote_api_id (the taskseries ID).

wtf? taskseries? Yeah, I'm not going to go into RTM internals here. Some things don't map 1:1. No clue what I'm going to do about recurring tasks. IMO those should either be dailies or ignored. Also I should fill in the due date field from RTM. But that's like...goal 7.

pjf commented 11 years ago

Wait, we can add our own properties? Is that via PUT and POST? Holy smokes! I have to code now!

wizonesolutions commented 11 years ago

@pjf You inspired me to believe this, actually, when you said that PUT bestowed superpowers.

wizonesolutions commented 11 years ago

Opened #2. Don't need to deal with recurring tasks yet. Those are the exception, and not having them is not doing to make me miss out on tons of XP. I actually have very few recurring tasks these days. I use Dailies a lot more now. Way more fun, and if you don't do them they just reset instead of hanging around.

wizonesolutions commented 11 years ago

Goal 2 achieved! OK, next goal is to delete tasks that have been deleted on the RTM side. Hmm...I might have to implement #3 for this. Well, better now than never.

wizonesolutions commented 11 years ago

Alright, #3 done and working on deleting tasks on our end that have been deleted on the RTM side. RTM helpfully tells us all the deleted taskseries object per list when we specify last_sync. So just a matter of going through these. Goal 3 is nigh.

wizonesolutions commented 11 years ago

Oops...that was the wrong issue number...

wizonesolutions commented 11 years ago

Goal 3 appears achieved. I feel like I am going to run into all kinds of annoying edge cases, but this feature will likely get some debugging as I test the next steps.

The final step to call this v1 is to complete remote RTM tasks when they are completed in Habit. This is actually a little tricky.

I'm going to store an hts_known_complete property on the tasks I add, which will be "uncompleted" by default. It will compare this to its actual status, and if it differs it will blindly try to delete the task on the RTM side. If it gets an error, it will just ignore it and keep going.

One problem is what to do if a task has been completed on our end but deleted remotely. Actually, I guess it's alright to delete it. We've already gotten the credit for it in that case.

Also need to filter for incomplete tasks only. ALWAYS. I might need to ignore smart lists too, but that isn't priority 1.

wizonesolutions commented 11 years ago

Hmm, status:incomplete in the filter might filter out the deleted tasks too. Need to test this.