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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Languages:
{07CCCAAE-6E9C-4C6A-A6EE-7EDAD7C40185}
{AF3DC2D0-D8B8-43B1-9C6E-61F64CC3198C}
{4DA960C5-89FD-4532-BB70-23DB25E1F34D}
{B7177F06-E9A6-4D30-8181-3D4D10F4C384}
- ID: "25bed78c-4957-4165-998a-ca1b52f67497"
Hint: __Created
Value: 20240224T140709Z
Expand All @@ -23,14 +24,14 @@ Languages:
<link class="" id="{AEB7B39D-711E-453D-A8DA-3A897C69DC56}" querystring="" anchor="" target="" title="" linktype="internal" text="" url="/MvpSite/Home/Directory/Profile" />
- ID: "8cdc337e-a112-42fb-bbb4-4143751e123f"
Hint: __Revision
Value: "17706c7e-151a-4e3e-a459-0e6de31db3c4"
Value: "c209d8eb-6093-47eb-832c-3b0546c22527"
- ID: "badd9cf9-53e0-4d0c-bcc0-2d784c282f6a"
Hint: __Updated by
Value: |
sitecore\ed7gR4aY22
sitecore\ivan.lieckens@sitecore.com
- ID: "d9cf14b1-fa16-4ba6-9288-e8a174d4d522"
Hint: __Updated
Value: 20240327T161344Z
Value: 20250416T075635Z
- ID: "f496f42f-25b9-4493-a287-d2eb04022623"
Hint: DirectoryLink
Value: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
ID: "b7177f06-e9a6-4d30-8181-3d4d10f4c384"
Parent: "cbf7a100-f126-4379-8175-f325b53d7516"
Template: "979d80e0-68df-4d8c-b5f6-f5552e59908f"
Path: /sitecore/content/MvpSite/Shared Content/Directory/Mentor
SharedFields:
- ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
Hint: __Sortorder
Value: 300
- ID: "dbbbeca1-21c7-4906-9dd2-493c1efa59a2"
Hint: __Shared revision
Value: "494aca7c-161a-4568-a78b-b6c5d0262b41"
Languages:
- Language: en
Versions:
- Version: 1
Fields:
- ID: "25bed78c-4957-4165-998a-ca1b52f67497"
Hint: __Created
Value: 20250415T120029Z
- ID: "2a85879e-bfde-4aae-8481-d3844c22be37"
Hint: Name
Value: Mentor
- ID: "52807595-0f8f-4b20-8d2a-cb71d28c6103"
Hint: __Owner
Value: |
sitecore\ivan.lieckens@sitecore.com
- ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
Hint: __Created by
Value: |
sitecore\ivan.lieckens@sitecore.com
- ID: "8cdc337e-a112-42fb-bbb4-4143751e123f"
Hint: __Revision
Value: "8e39b7d5-db01-4520-8f9a-6e06dbd0b60d"
- ID: "badd9cf9-53e0-4d0c-bcc0-2d784c282f6a"
Hint: __Updated by
Value: |
sitecore\ivan.lieckens@sitecore.com
- ID: "d9cf14b1-fa16-4ba6-9288-e8a174d4d522"
Hint: __Updated
Value: 20250415T120040Z
- ID: "df2c9a26-a2d0-4529-9ee8-8ed346614b02"
Hint: Identifier
Value: mentor
2 changes: 1 addition & 1 deletion headapps/MvpSite/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageVersion Include="Microsoft.AspNetCore.Session" Version="2.2.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
<PackageVersion Include="Okta.AspNetCore" Version="4.5.0" />
<PackageVersion Include="Mvp.Selections.Client" Version="4.21.1" />
<PackageVersion Include="Mvp.Selections.Client" Version="4.22.0" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageVersion Include="Markdig" Version="0.37.0" />
</ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions headapps/MvpSite/MvpSite.Rendering/Extensions/BooleanExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace MvpSite.Rendering.Extensions;

public static class BooleanExtensions
{
public static string ToStringOrNullLiteral(this bool? boolean)
{
string result = "null";
if (boolean.HasValue)
{
result = boolean.Value ? "true" : "false";
}

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Mvp.Selections.Api.Model;
using Mvp.Selections.Client;
using Mvp.Selections.Client.Models;
using Mvp.Selections.Domain;
using MvpSite.Rendering.Configuration;
using MvpSite.Rendering.Extensions;
using MvpSite.Rendering.Helpers;
Expand All @@ -31,6 +30,12 @@ public class DirectoryViewComponent(IViewModelBinder modelBinder, MvpSelectionsA

public const string CountryFacetIdentifier = "country";

public const string MentorFacetIdentifier = "mentor";

public const string MentorFacetOptionIdentifier = "mentor";

public const string OpenToMenteesOptionIdentifier = "openToMentees";

private const string SearchCacheKeyPrefix = "SearchMvpProfileAsync_";

private readonly MvpPeopleOptions _options = options.Value;
Expand Down Expand Up @@ -90,6 +95,21 @@ private static void MergeFacetsAndViewFacets(DirectoryViewModel model)
return result;
}

// NOTE [IVA] We only want null or true for facets otherwise we accidentally use negative filtering which creates unexpected results
private static bool? ExtractFacetBoolean(IEnumerable<FacetViewModel> facets, string facetIdentifier, string optionIdentifier)
{
bool? result = null;
FacetViewModel? facet = facets.FirstOrDefault(f => f.Identifier == facetIdentifier);
if (
facet != null &&
(facet.FacetOptions.FirstOrDefault(o => o.Identifier == optionIdentifier)?.IsActive ?? false))
{
result = true;
}

return result;
}

private static void MergeFacetOptions(FacetViewModel viewFacet, IEnumerable<SearchFacetOption> options)
{
foreach (SearchFacetOption option in options)
Expand Down Expand Up @@ -119,8 +139,10 @@ private async Task ExecuteSearch(DirectoryViewModel model)
List<short>? mvpTypeFacetIdentifiers = ExtractSearchIdentifiers(model.ViewFacets, MvpTypeFacetIdentifier);
List<short>? yearFacetIdentifiers = ExtractSearchIdentifiers(model.ViewFacets, YearFacetIdentifier);
List<short>? countryFacetIdentifiers = ExtractSearchIdentifiers(model.ViewFacets, CountryFacetIdentifier);
bool? mentor = ExtractFacetBoolean(model.ViewFacets, MentorFacetIdentifier, MentorFacetOptionIdentifier);
bool? openToMentees = ExtractFacetBoolean(model.ViewFacets, MentorFacetIdentifier, OpenToMenteesOptionIdentifier);
string cacheKey =
$"{SearchCacheKeyPrefix}{model.Query}_{mvpTypeFacetIdentifiers.ToCommaSeparatedStringOrNullLiteral()}_{yearFacetIdentifiers.ToCommaSeparatedStringOrNullLiteral()}_{countryFacetIdentifiers.ToCommaSeparatedStringOrNullLiteral()}_p{model.Page}/{model.PageSize}";
$"{SearchCacheKeyPrefix}{model.Query}_{mvpTypeFacetIdentifiers.ToCommaSeparatedStringOrNullLiteral()}_{yearFacetIdentifiers.ToCommaSeparatedStringOrNullLiteral()}_{countryFacetIdentifiers.ToCommaSeparatedStringOrNullLiteral()}_{mentor.ToStringOrNullLiteral()}_{openToMentees.ToStringOrNullLiteral()}_p{model.Page}/{model.PageSize}";
bool isAdmin = await new MvpSelectionsApiHelper(client).IsCurrentUserAnAdmin();
if (isAdmin || !cache.TryGetValue(cacheKey, out SearchResult<MvpProfile>? profiles))
{
Expand All @@ -129,6 +151,8 @@ private async Task ExecuteSearch(DirectoryViewModel model)
mvpTypeFacetIdentifiers,
yearFacetIdentifiers,
countryFacetIdentifiers,
mentor,
openToMentees,
model.Page,
model.PageSize);
if (response is { StatusCode: HttpStatusCode.OK, Result: not null })
Expand Down
Loading