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

Uniqueness search and updates to merge scripts #783

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##Make sure to use the compare menu first.
##Once the additional regulation is loaded, its name should appear in both the menu and at the top of the field list.
newvar regulationFolderName:mod;
auxparam $regulationFolderName .*: !conflicts: paste;
param .*: conflicts: !modified && auxmodified $regulationFolderName: = aux $regulationFolderName;
auxparam $regulationFolderName .*: !conflicts && unique ID: paste;
param .*: conflicts && unique ID: !modified && auxmodified $regulationFolderName: = aux $regulationFolderName;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Make sure to use the compare menu first.
##Once the additional regulation is loaded, its name should appear in both the menu and at the top of the field list.
newvar regulationFolderName:mod;
auxparam $regulationFolderName .*: modified: paste;
auxparam $regulationFolderName .*: modified && unique ID: paste;
16 changes: 16 additions & 0 deletions src/StudioCore/ParamEditor/SearchEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,22 @@ internal override void Setup()
};
};
}, () => CFG.Current.Param_AdvancedMassedit));
filterList.Add("unique", newCmd(new string[] { "field" }, "Selects all rows where the value in the given field is unique", (args, lenient) =>
{
string field = args[0].Replace(@"\s", " ");
return (param) =>
{
var col = param.Item2.GetCol(field);
if (!col.IsColumnValid())
throw new Exception("Could not find field " + field);
var distribution = ParamUtils.GetParamValueDistribution(param.Item2.Rows, col);
var setOfDuped = distribution.Where((entry, linqi) => entry.Item2 > 1).Select((entry, linqi) => entry.Item1).ToHashSet();
return (row) =>
{
return !setOfDuped.Contains(row.Get(col));
};
};
}, () => CFG.Current.Param_AdvancedMassedit));
defaultFilter = newCmd(new[] { "row ID or Name (regex)" },
"Selects rows where either the ID or Name matches the given regex, except in strict/massedit mode",
(args, lenient) =>
Expand Down
Loading