Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE-3709] Fix dragging of tasks in CW that have predecessors #449

Conversation

zeryab-topleft
Copy link
Contributor

No description provided.

@zeryab-topleft zeryab-topleft force-pushed the 3709-fix-dragging-of-tasks-in-cw-that-have-predecessors branch 2 times, most recently from 5b1a5c9 to daefd87 Compare November 4, 2024 15:07

predecessor_reset_fields = {
'ticket_predecessor': None,
'required_date_utc': None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the required_date_utc NEED to be set as none for this as well? I don't think it does, and that creates the problem of it also removing this and never adding it back. Check to make sure we don't have to null this field.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, also this appears to happen when even the start date is updated. So if a user updates a start date, doesn't this erase the required date and then not add it back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the required_date_utc NEED to be set as none for this as well? I don't think it does, and that creates the problem of it also removing this and never adding it back. Check to make sure we don't have to null this field.

Yes, I have added it on purpose if we don't remove the required_date_utc or estimated_start_date the same dependency error occurs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, also this appears to happen when even the start date is updated. So if a user updates a start date, doesn't this erase the required date and then not add it back?

Yes, if a ticket has predecessor and user change either start or end date we need to set both to null and then set the date. Otherwise the dependecy error occurs

predecessor_reset = False
except ConnectWiseAPIError as e:
error_message = \
"Failed to reset predecessor fields for record " + \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good internal logging message, but it means nothing for the user. They don't need to know and probably wont understand why this step is important, and it doesn't give them any indication of what they need to do. It would be better to just tell them that the update request failed, and to refresh and try again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

updated_record = client.update_ticket(record, api_fields)
except ConnectWiseAPIError as e:
error_message = \
f"Failed to update record {record.id} with changed fields."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also too generic for the user, and doesn't help them understand what to do next. Fix similar to the comment on line 2948

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

f"Failed to update record {record.id} with changed fields."
if not predecessor_reset:
error_message = (
f"Failed to update record {record.id} after " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message is also not great for the user. We need to be very clear that something has gone wrong and the predecessor is gone and they need to fix it. Something like:

"An error occurred while updating record {id} and the predecessor has been removed from the ticket. You must re-add the predecessor manually to the ticket."

Its also a good idea to do this in 3 operations instead of 2. While 3 does give it more opportunities to fail, if the first two succeed, then the data they wanted to change is still changed, they just need to fix the predecessor. If the second one fails but the third succeeds, then we can at least set it back to what it was before they tried. If the first fails, we just show a message to try again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the error message, also if we do it using 3 api calls it still fails with dependency error. So I have to do it with 2 where I need to set the start and end Date along with predecessor at time.

@ssarwar-topleft ssarwar-topleft force-pushed the 3709-fix-dragging-of-tasks-in-cw-that-have-predecessors branch 2 times, most recently from 6904af0 to 3d4169c Compare November 12, 2024 15:16
@zeryab-topleft zeryab-topleft force-pushed the 3709-fix-dragging-of-tasks-in-cw-that-have-predecessors branch from 3d4169c to d6a66b5 Compare November 12, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants