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

Have a DiffSyncModel property (like a datetime) be a tiebreaker if there is a diff #200

Open
draggeta opened this issue Jan 19, 2023 · 2 comments
Labels
status: internal review Internal discussion is required to move forward with issue type: enhancement

Comments

@draggeta
Copy link

draggeta commented Jan 19, 2023

Environment

  • DiffSync version: 1.7.0

Proposed Functionality

I do not know if this is possible with a custom diff, but I would love to have the capability to check if items should be synchronized based on a value like modified date.

Use Case

Basically if an object looks like this:

class Issue(DiffSyncModel):
    _modelname = "issue"
    _identifiers = ("id",)
    _shortname = ()
    _attributes = ("assignee",)
    _children = {}

    id: str
    assignee: str
    modified_date: datetime.DateTime

I'd like to be able to decide which side wins (if there is a diff) based on the modified_date. This would mean that modified_date is ignored in the diff unless there is a difference. In those cases it will be the tiebreaker.

@Kircheneer
Copy link
Collaborator

So what you are proposing is to have an attribute on a model that decides what the direction of the sync should be? As in, you instantiate both of your DiffSync subclass instances, and then instead of calling sync_from or sync_to, your proposal is to just call something like diffsync_a.sync(diffsync_b) and have each individual model decide which record "wins"?

@Kircheneer Kircheneer added status: action required This issue requires additional information to be actionable type: major feature labels Jan 22, 2023
@draggeta
Copy link
Author

draggeta commented Jan 23, 2023

Hi @Kircheneer,

It could be a sync method or a call to sync_to or sync_from, where diffsync will use the same property to check if it should overwrite the destination (or not).

@Kircheneer Kircheneer added status: internal review Internal discussion is required to move forward with issue and removed status: action required This issue requires additional information to be actionable labels Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: internal review Internal discussion is required to move forward with issue type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants