fix: habit updates losing data due to partial API updates#32
Open
kozy-codes wants to merge 1 commit intodev-mirzabicer:mainfrom
Open
fix: habit updates losing data due to partial API updates#32kozy-codes wants to merge 1 commit intodev-mirzabicer:mainfrom
kozy-codes wants to merge 1 commit intodev-mirzabicer:mainfrom
Conversation
- TickTick habits/batch API requires full object replacement, not partial updates - Added missing parameters to update_habit() (sort_order, target_start_date, etc.) - Added full_update_habit() method for sending complete habit objects - Updated checkin_habit(), archive_habit(), unarchive_habit() to preserve all fields - Fixes issue where habit check-ins would disappear after being recorded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Habit check-ins and updates were disappearing after being recorded. For example, checking into a habit would initially show success, but the check-in would vanish shortly after.
Root Cause
TickTick's
habits/batchAPI requires full object replacement, not partial updates. When only some fields are sent in an update request, the omitted fields are reset to their default values (null/0).This means:
name,color,goal, etc.Solution
Modified all habit update operations to:
Changes
src/ticktick_sdk/api/v2/client.pyAdded missing parameters to
update_habit():sort_ordertarget_start_datecompleted_cyclesex_datesstyleetagcreated_timeAdded new method
full_update_habit(habit_data: dict)for sending complete habit dictionaries directly to the batch APIsrc/ticktick_sdk/unified/api.pyUpdated the following methods to fetch original habit and send all fields:
update_habit()- Now preserves all original fields when updating specific propertiescheckin_habit()- Usesfull_update_habit()with completeHabitobject converted viato_v2_dict()archive_habit()- Sends all fields withstatus=2unarchive_habit()- Sends all fields withstatus=0batch_checkin_habits()- Usesfull_update_habit()for each habit updateTesting