Skip to content

Commit

Permalink
if there is even a single non-empty label in a column and we are auto…
Browse files Browse the repository at this point in the history
…sorting we should really just replace everything by Label
  • Loading branch information
JorisGoosen committed Nov 6, 2024
1 parent 42d471e commit debe9a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions CommonData/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1821,9 +1821,9 @@ void Column::labelsOrderByValue(bool doDbUpdateEtc)
static double dummy;

for(Label * label : labels())
if(!label->isEmptyValue() && !(label->originalValue().isDouble() || ColumnUtils::getDoubleValue(label->originalValueAsString(), dummy)))
if(!label->isEmptyValue())
{
replaceAllDoubles = true;
replaceAllDoubles = true; // because if there is any label at all it will show up at the end after the doubles without a Label. If this label is a double and the same as the label we could try to turn it back into a non-Label. But it still would break for Labels with a double value and a non-double label. So instead lets just make a label for everything. We keep the doubles only if there are only doubles. This should speed up a lot of operations for massive double datasets so its worth the extra hassle I guess. Just like you, who just read to the end of this line that really really breaks the 80's guideline of 80 characterwide code ;)
break;
}

Expand Down
30 changes: 15 additions & 15 deletions Desktop/data/computedcolumnmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void ComputedColumnModel::recomputeColumn(QString columnName)
std::string colName = fq(columnName);
Column * col = dataSet()->column(colName);

if(col && col->isComputed() && col->codeType() != computedColumnType::analysis && col->codeType() == computedColumnType::analysisNotComputed)
if(col && col->isComputed() && col->codeType() == computedColumnType::analysisNotComputed)
DataSetPackage::pkg()->columnSetDefaultValues(colName);

checkForDependentColumnsToBeSent(columnName, col && col->isComputed());
Expand Down Expand Up @@ -295,23 +295,23 @@ void ComputedColumnModel::checkForDependentColumnsToBeSent(QString columnNameQ,
void ComputedColumnModel::checkForDependentAnalyses(const std::string & columnName)
{
Analyses::analyses()->applyToAll([&](Analysis * analysis)
{
stringset usedCols = analysis->usedVariables(),
createdCols = analysis->createdVariables();
{
stringset usedCols = analysis->usedVariables(),
createdCols = analysis->createdVariables();

//Dont create an infinite loop please, but do this only for non-computed columns created by an analysis (aka distributions, because otherwise it breaks things like planning from audit)
if(usedCols.count(columnName) && (!createdCols.count(columnName) || !DataSetPackage::pkg()->isColumnAnalysisNotComputed(columnName)))
{
bool allColsValidated = true;
//Dont create an infinite loop please, but do this only for non-computed columns created by an analysis (aka distributions, because otherwise it breaks things like planning from audit)
if(usedCols.count(columnName) && (!createdCols.count(columnName) || !DataSetPackage::pkg()->isColumnAnalysisNotComputed(columnName)))
{
bool allColsValidated = true;

for(Column * col : computedColumns())
if(usedCols.count(col->name()) > 0 && col->invalidated())
allColsValidated = false;
for(Column * col : computedColumns())
if(usedCols.count(col->name()) > 0 && col->invalidated())
allColsValidated = false;

if(allColsValidated)
analysis->refresh();
}
});
if(allColsValidated)
analysis->refresh();
}
});
}

void ComputedColumnModel::removeColumn()
Expand Down

0 comments on commit debe9a5

Please sign in to comment.