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

add import mode to update datasets without deleting existing data #308

Open
wants to merge 3 commits into
base: development
Choose a base branch
from

Conversation

eperedo
Copy link

@eperedo eperedo commented Oct 6, 2023

📌 References

📝 Implementation

🔥 Notes for the reviewer

📹 Screenshots/Screen capture

  • New button to import data without deleting existing dataValues: IMPORT AND UPDATE
    image

Help Message

image

  • DELETE AND IMPORT help message (previous "PROCEED")
    image

  • IMPORT ONLY NEW DATA VALUES help message
    image

📑 Others

Copy link

@tokland tokland left a comment

Choose a reason for hiding this comment

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

Is this PR still a draft?

The feature works (just added a note about the default behavior). And just some very minor things we can check before merging, inline.

public async importDataPackage(dataPackage: DataPackage): Promise<SynchronizationResult[]> {
public async importDataPackage(
dataPackage: DataPackage,
createAndUpdate: boolean
Copy link

@tokland tokland Jan 2, 2024

Choose a reason for hiding this comment

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

Typically, it's better to use an options argument that wraps boolean options. This way, calls to the method are more declarative.

return true;
} else {
return false;
}
Copy link

Choose a reason for hiding this comment

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

Equivalent return strategy === "IMPORT"

@@ -45,7 +40,7 @@ export default function ImportTemplatePage({ settings }: RouteComponentProps) {
const [orgUnitTreeFilter, setOrgUnitTreeFilter] = useState<string[]>([]);
const [importState, setImportState] = useState<ImportState>();
const [messages, setMessages] = useState<string[]>([]);
const [dialogProps, updateDialog] = useState<ConfirmationDialogProps | null>(null);
const [dialogProps, updateDialog] = useState<ModalDialogProps | null>(null);
Copy link

Choose a reason for hiding this comment

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

It's more idiomatic to use undefined as initial empty value of a useState. Then we can simply write: useState<ConfirmationDialogProps>();

"IMPORT ONLY NEW DATA VALUES, WITHOUT UPDATING OR DELETING CURRENT ONES"
),
updateTooltipText: i18n.t(
"IMPORT AND UPDATE DATA VALUES WITHOUT DELETING THE REMAINING EXISTING DATA"
Copy link

@tokland tokland Jan 2, 2024

Choose a reason for hiding this comment

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

Typically, we use standard case for texts (and the CSS decides how it's shown).

switch (dataPackage.type) {
case "dataSets": {
const result = await this.importAggregatedData("CREATE_AND_UPDATE", dataPackage);
const result = await this.importAggregatedData(
createAndUpdate ? "CREATE_AND_UPDATE" : "CREATE",
Copy link

@tokland tokland Jan 2, 2024

Choose a reason for hiding this comment

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

[note] When Duplicate detection is not enabled, duplicateStrategy is "ERROR" so the default importStrategy is now CREATE instead of CREATE_AND_UPDATE. That's possibly a feature, not a bug, but I wanted to note it as it will change our default behavior for everyone.

@eperedo eperedo marked this pull request as ready for review October 1, 2024 23:49
@eperedo eperedo requested review from Ramon-Jimenez and tokland and removed request for saragilcas October 1, 2024 23:50
Copy link

@Ramon-Jimenez Ramon-Jimenez left a comment

Choose a reason for hiding this comment

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

All good (functional testing). Waiting for feedback from @tokland before merging this.

@tokland
Copy link

tokland commented Oct 29, 2024

@eperedo Is the base branch correct? or maybe development merge pending?

@eperedo eperedo force-pushed the feat/datavalues-import-strategy branch from d1e120e to e989446 Compare October 31, 2024 12:38
Copy link

@tokland tokland left a comment

Choose a reason for hiding this comment

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

[code-only review] All good.

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