Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

[Package Renames] Add feature flag to disable popularity transfers #773

Merged
merged 7 commits into from
May 1, 2020

Conversation

loic-sharma
Copy link
Contributor

@loic-sharma loic-sharma commented Apr 24, 2020

Adds the feature flag Search.TransferPopularity that, if disabled, removes all popularity transfers on the search index. Note that download overrides are still applied even if the popularity transfer feature flag is disabled.

Addresses NuGet/NuGetGallery#7944
The feature flag staleness monitoring is tracked by NuGet/NuGetGallery#7966

@@ -171,6 +174,19 @@ private async Task<bool> PushIndexChangesAsync()
return true;
}

private async Task<SortedDictionary<string, SortedSet<string>>> GetPopularityTransfersAsync()
{
if (!_featureFlags.IsPopularityTransferEnabled())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: personally I feel an enabled check is more readable and intuitive than not enabled..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer the negative pattern as it avoids nesting if there are multiple conditions that must be met before returning the result. For example:

if (condition1)
{
    if (condition2)
    {
        return data;
    }
    else
    {
        return errorResult2;
    }
}
else
{
    return errorResult1;
}

return emptyResults;

Vs:

if (!condition1)
{
    return errorResult1;
}

if (!condition2)
{
    return errorResult2;
}

return results;

Please let me know if you feel strongly about this.

@loic-sharma loic-sharma merged commit 136e8b1 into dev May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants