Skip to content
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
79 changes: 0 additions & 79 deletions src/Umbraco.Core/Services/IMemberService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,85 +328,6 @@ IEnumerable<IMember> FindMembersByDisplayName(
out long totalRecords,
StringPropertyMatchType matchType = StringPropertyMatchType.StartsWith);

/// <summary>
/// Gets a list of Members based on a property search
/// </summary>
/// <param name="propertyTypeAlias">Alias of the PropertyType to search for</param>
/// <param name="value"><see cref="string" /> Value to match</param>
/// <param name="matchType">
/// The type of match to make as <see cref="StringPropertyMatchType" />. Default is
/// <see cref="StringPropertyMatchType.Exact" />
/// </param>
/// <returns>
/// <see cref="IEnumerable{IMember}" />
/// </returns>
/// <remarks>
/// Instead of using this method, which queries the database directly, we advise using search (Examine).
/// You can configure an `IValueSetValidator` to ensure all the properties you need are indexed.
/// <see href="https://docs.umbraco.com/umbraco-cms/reference/searching/examine/indexing#changing-ivaluesetvalidator" />
/// </remarks>
[Obsolete("Please use Search (Examine) instead, scheduled for removal in Umbraco 18.")]
IEnumerable<IMember> GetMembersByPropertyValue(
string propertyTypeAlias,
string value,
StringPropertyMatchType matchType = StringPropertyMatchType.Exact);

/// <summary>
/// Gets a list of Members based on a property search
/// </summary>
/// <param name="propertyTypeAlias">Alias of the PropertyType to search for</param>
/// <param name="value"><see cref="int" /> Value to match</param>
/// <param name="matchType">
/// The type of match to make as <see cref="StringPropertyMatchType" />. Default is
/// <see cref="StringPropertyMatchType.Exact" />
/// </param>
/// <returns>
/// <see cref="IEnumerable{IMember}" />
/// </returns>
/// <remarks>
/// Instead of using this method, which queries the database directly, we advise using search (Examine).
/// You can configure an `IValueSetValidator` to ensure all the properties you need are indexed.
/// <see href="https://docs.umbraco.com/umbraco-cms/reference/searching/examine/indexing#changing-ivaluesetvalidator" />
/// </remarks>
[Obsolete("Please use Search (Examine) instead, scheduled for removal in Umbraco 18.")]
IEnumerable<IMember> GetMembersByPropertyValue(string propertyTypeAlias, int value, ValuePropertyMatchType matchType = ValuePropertyMatchType.Exact);

/// <summary>
/// Gets a list of Members based on a property search
/// </summary>
/// <param name="propertyTypeAlias">Alias of the PropertyType to search for</param>
/// <param name="value"><see cref="bool" /> Value to match</param>
/// <returns>
/// <see cref="IEnumerable{IMember}" />
/// </returns>
/// <remarks>
/// Instead of using this method, which queries the database directly, we advise using search (Examine).
/// You can configure an `IValueSetValidator` to ensure all the properties you need are indexed.
/// <see href="https://docs.umbraco.com/umbraco-cms/reference/searching/examine/indexing#changing-ivaluesetvalidator" />
/// </remarks>
[Obsolete("Please use Search (Examine) instead, scheduled for removal in Umbraco 18.")]
IEnumerable<IMember> GetMembersByPropertyValue(string propertyTypeAlias, bool value);

/// <summary>
/// Gets a list of Members based on a property search
/// </summary>
/// <param name="propertyTypeAlias">Alias of the PropertyType to search for</param>
/// <param name="value"><see cref="System.DateTime" /> Value to match</param>
/// <param name="matchType">
/// The type of match to make as <see cref="StringPropertyMatchType" />. Default is
/// <see cref="StringPropertyMatchType.Exact" />
/// </param>
/// <returns>
/// <see cref="IEnumerable{IMember}" />
/// </returns>
/// <remarks>
/// Instead of using this method, which queries the database directly, we advise using search (Examine).
/// You can configure an `IValueSetValidator` to ensure all the properties you need are indexed.
/// <see href="https://docs.umbraco.com/umbraco-cms/reference/searching/examine/indexing#changing-ivaluesetvalidator" />
/// </remarks>
[Obsolete("Please use Search (Examine) instead, scheduled for removal in Umbraco 18.")]
IEnumerable<IMember> GetMembersByPropertyValue(string propertyTypeAlias, DateTime value, ValuePropertyMatchType matchType = ValuePropertyMatchType.Exact);

/// <summary>
/// Saves only the properties related to login for the member, using an optimized, non-locking update.
/// </summary>
Expand Down
105 changes: 0 additions & 105 deletions src/Umbraco.Core/Services/MemberService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Extensions.DependencyInjection;

Check notice on line 1 in src/Umbraco.Core/Services/MemberService.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (v18/dev)

✅ Getting better: Code Duplication

reduced similar code in: GetMembersByPropertyValue,GetMembersByPropertyValue. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check notice on line 1 in src/Umbraco.Core/Services/MemberService.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (v18/dev)

✅ Getting better: String Heavy Function Arguments

The ratio of strings in function arguments decreases from 44.14% to 44.08%, threshold = 39.0%. The functions in this file have a high ratio of strings as arguments. Avoid adding more.
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Events;
Expand Down Expand Up @@ -722,112 +722,7 @@

return _memberRepository.GetPage(query, pageIndex, pageSize, out totalRecords, propertyAliases: null, filter: null, Ordering.By("LoginName"));
}

Check notice on line 725 in src/Umbraco.Core/Services/MemberService.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (v18/dev)

✅ No longer an issue: Complex Method

GetMembersByPropertyValue is no longer above the threshold for cyclomatic complexity. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check notice on line 725 in src/Umbraco.Core/Services/MemberService.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (v18/dev)

✅ No longer an issue: Complex Method

GetMembersByPropertyValue is no longer above the threshold for cyclomatic complexity. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check notice on line 725 in src/Umbraco.Core/Services/MemberService.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (v18/dev)

✅ No longer an issue: Complex Method

GetMembersByPropertyValue is no longer above the threshold for cyclomatic complexity. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
/// <inheritdoc />
[Obsolete("Please use Search (Examine) instead, scheduled for removal in Umbraco 18.")]
public IEnumerable<IMember> GetMembersByPropertyValue(string propertyTypeAlias, string value, StringPropertyMatchType matchType = StringPropertyMatchType.Exact)
{
using ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true);
scope.ReadLock(Constants.Locks.MemberTree);
IQuery<IMember> query;

switch (matchType)
{
case StringPropertyMatchType.Exact:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && (((Member) x).LongStringPropertyValue!.SqlEquals(value, TextColumnType.NText) || ((Member) x).ShortStringPropertyValue!.SqlEquals(value, TextColumnType.NVarchar)));
break;
case StringPropertyMatchType.Contains:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && (((Member) x).LongStringPropertyValue!.SqlContains(value, TextColumnType.NText) || ((Member) x).ShortStringPropertyValue!.SqlContains(value, TextColumnType.NVarchar)));
break;
case StringPropertyMatchType.StartsWith:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && (((Member) x).LongStringPropertyValue.SqlStartsWith(value, TextColumnType.NText) || ((Member) x).ShortStringPropertyValue.SqlStartsWith(value, TextColumnType.NVarchar)));
break;
case StringPropertyMatchType.EndsWith:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && (((Member) x).LongStringPropertyValue!.SqlEndsWith(value, TextColumnType.NText) || ((Member) x).ShortStringPropertyValue!.SqlEndsWith(value, TextColumnType.NVarchar)));
break;
default:
throw new ArgumentOutOfRangeException(nameof(matchType));
}

return _memberRepository.Get(query);
}

/// <inheritdoc />
[Obsolete("Please use Search (Examine) instead, scheduled for removal in Umbraco 18.")]
public IEnumerable<IMember> GetMembersByPropertyValue(string propertyTypeAlias, int value, ValuePropertyMatchType matchType = ValuePropertyMatchType.Exact)
{
using ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true);
scope.ReadLock(Constants.Locks.MemberTree);
IQuery<IMember> query;

switch (matchType)
{
case ValuePropertyMatchType.Exact:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).IntegerPropertyValue == value);
break;
case ValuePropertyMatchType.GreaterThan:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).IntegerPropertyValue > value);
break;
case ValuePropertyMatchType.LessThan:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).IntegerPropertyValue < value);
break;
case ValuePropertyMatchType.GreaterThanOrEqualTo:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).IntegerPropertyValue >= value);
break;
case ValuePropertyMatchType.LessThanOrEqualTo:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).IntegerPropertyValue <= value);
break;
default:
throw new ArgumentOutOfRangeException(nameof(matchType));
}

return _memberRepository.Get(query);
}

/// <inheritdoc />
[Obsolete("Please use Search (Examine) instead, scheduled for removal in Umbraco 18.")]
public IEnumerable<IMember> GetMembersByPropertyValue(string propertyTypeAlias, bool value)
{
using ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true);
scope.ReadLock(Constants.Locks.MemberTree);
IQuery<IMember> query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).BoolPropertyValue == value);

return _memberRepository.Get(query);
}

/// <inheritdoc />
[Obsolete("Please use Search (Examine) instead, scheduled for removal in Umbraco 18.")]
public IEnumerable<IMember> GetMembersByPropertyValue(string propertyTypeAlias, DateTime value, ValuePropertyMatchType matchType = ValuePropertyMatchType.Exact)
{
using ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true);
scope.ReadLock(Constants.Locks.MemberTree);
IQuery<IMember> query;

switch (matchType)
{
case ValuePropertyMatchType.Exact:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).DateTimePropertyValue == value);
break;
case ValuePropertyMatchType.GreaterThan:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).DateTimePropertyValue > value);
break;
case ValuePropertyMatchType.LessThan:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).DateTimePropertyValue < value);
break;
case ValuePropertyMatchType.GreaterThanOrEqualTo:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).DateTimePropertyValue >= value);
break;
case ValuePropertyMatchType.LessThanOrEqualTo:
query = Query<IMember>().Where(x => ((Member) x).PropertyTypeAlias == propertyTypeAlias && ((Member) x).DateTimePropertyValue <= value);
break;
default:
throw new ArgumentOutOfRangeException(nameof(matchType)); // causes rollback // causes rollback
}

// TODO: Since this is by property value, we need a GetByPropertyQuery on the repo!
return _memberRepository.Get(query);
}

/// <summary>
/// Checks if a Member with the id exists
/// </summary>
Expand Down
Loading
Loading