fixed merge route

This commit is contained in:
nvrl committed 2026-06-15 17:44:56 +02:00
1 parent befe773aa7
commit 4ec3464d99
2 files changed
+6 -2

No files matched your search

+5 -1
View File
@@ -491,6 +491,10 @@ async fn upsert_flavor(
.filter(flavor::Column::ExternalId.eq(external_id))
.one(db)
.await?;
// A row already linked by external_id is the authoritative one for this
// product; its name may have been curated (admin rename) or chosen by a merge
// that kept the legacy row. Don't let a later sync overwrite that name.
let matched_by_external = existing.is_some();
if existing.is_none() {
existing = Flavor::find()
.filter(flavor::Column::Name.eq(name))
@@ -527,7 +531,7 @@ async fn upsert_flavor(
if f_is_legacy {
am.is_legacy = Set(false);
}
if f_name != name {
if f_name != name && !matched_by_external {
let dup = Flavor::find()
.filter(flavor::Column::Name.eq(name))
.filter(flavor::Column::CategoryId.eq(category_id))
+1 -1
View File
@@ -38,7 +38,7 @@ const AdminFlavors: React.FC = () => {
setIsMerging(true);
try {
await api.post('admin/merge_flavors/', {
await api.post('admin-custom/merge_flavors/', {
keep_id: keepFlavor.id,
remove_id: removeFlavor.id,
});