Skip to content

Commit

Permalink
Removed is searchable and sort for search param in reindex (#3432)
Browse files Browse the repository at this point in the history
* Removed is searchable and sort for search param checks for reindex. They are no longer needed.

* Update of reindex test.
  • Loading branch information
PTaladay authored Aug 4, 2023
1 parent 5d3a837 commit 069eafd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private async Task<bool> TryPopulateNewJobFields(CancellationToken cancellationT
// Find search parameters not in a final state such as supported, pendingDelete, pendingDisable.
List<SearchParameterStatus> validStatus = new List<SearchParameterStatus>() { SearchParameterStatus.Supported, SearchParameterStatus.PendingDelete, SearchParameterStatus.PendingDisable };
var searchParamStatusCollection = await _searchParameterStatusManager.GetAllSearchParameterStatus(cancellationToken);
var possibleNotYetIndexedParams = _searchParameterDefinitionManager.AllSearchParameters.Where(sp => validStatus.Contains(searchParamStatusCollection.First(p => p.Uri == sp.Url).Status) || sp.IsSearchable == false || sp.SortStatus == SortParameterStatus.Supported);
var possibleNotYetIndexedParams = _searchParameterDefinitionManager.AllSearchParameters.Where(sp => validStatus.Contains(searchParamStatusCollection.First(p => p.Uri == sp.Url).Status));
var notYetIndexedParams = new List<SearchParameterInfo>();

var resourceList = new HashSet<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using MediatR;
Expand Down Expand Up @@ -100,7 +101,7 @@ public async Task GivenSupportedParams_WhenExecuted_ThenCorrectSearchIsPerformed
{
// Get one search parameter and configure it such that it needs to be reindexed
var param = _searchDefinitionManager.AllSearchParameters.FirstOrDefault(p => p.Url == new Uri("http://hl7.org/fhir/SearchParameter/Account-status"));
param.IsSearchable = false;
await SetSearchParameterStatus(new ReadOnlyCollection<string>(new List<string>() { param.Url.OriginalString }), SearchParameterStatus.Supported);
var expectedResourceType = param.BaseResourceTypes.FirstOrDefault();

ReindexJobRecord job = CreateReindexJobRecord();
Expand Down Expand Up @@ -154,7 +155,7 @@ public async Task GivenContinuationToken_WhenExecuted_ThenAdditionalQueryAdded()
{
// Get one search parameter and configure it such that it needs to be reindexed
var param = _searchDefinitionManager.AllSearchParameters.FirstOrDefault(p => p.Code == "identifier");
param.IsSearchable = false;
await SetSearchParameterStatus(new ReadOnlyCollection<string>(new List<string>() { param.Url.OriginalString }), SearchParameterStatus.Supported);
var expectedResourceType = param.BaseResourceTypes.FirstOrDefault();

ReindexJobRecord job = CreateReindexJobRecord();
Expand Down Expand Up @@ -216,12 +217,12 @@ public async Task GivenRunningJob_WhenExecuted_ThenQueuedQueryCompleted()
Assert.NotNull(paramWithAppointmentResponseBaseType);
Assert.NotNull(paramWithAppointmentBaseType);

paramWithAppointmentResponseBaseType.IsSearchable = false;
paramWithAppointmentBaseType.IsSearchable = false;

var resourceTypeSearchParamHashMap = new Dictionary<string, string>();
resourceTypeSearchParamHashMap.Add("Appointment", "appointmentHash");
resourceTypeSearchParamHashMap.Add("AppointmentResponse", "appointmentResponseHash");
await SetSearchParameterStatus(new ReadOnlyCollection<string>(new List<string>() { paramWithAppointmentResponseBaseType.Url.OriginalString, paramWithAppointmentBaseType.Url.OriginalString }), SearchParameterStatus.Supported);
var resourceTypeSearchParamHashMap = new Dictionary<string, string>
{
{ "Appointment", "appointmentHash" },
{ "AppointmentResponse", "appointmentResponseHash" },
};

ReindexJobRecord job = CreateReindexJobRecord(paramHashMap: resourceTypeSearchParamHashMap);
_fhirOperationDataStore.GetReindexJobByIdAsync(job.Id, _cancellationToken).ReturnsForAnyArgs(new ReindexJobWrapper(job, _weakETag));
Expand Down Expand Up @@ -411,12 +412,12 @@ public async Task GivenJobWithNoWork_WhenExecuted_ThenJobCompletedAndSPStatusUpd
Assert.NotNull(paramWithAppointmentResponseBaseType);
Assert.NotNull(paramWithAppointmentBaseType);

paramWithAppointmentResponseBaseType.IsSearchable = false;
paramWithAppointmentBaseType.IsSearchable = false;

var resourceTypeSearchParamHashMap = new Dictionary<string, string>();
resourceTypeSearchParamHashMap.Add("Appointment", "appointmentHash");
resourceTypeSearchParamHashMap.Add("AppointmentResponse", "appointmentResponseHash");
await SetSearchParameterStatus(new ReadOnlyCollection<string>(new List<string>() { paramWithAppointmentResponseBaseType.Url.OriginalString, paramWithAppointmentBaseType.Url.OriginalString }), SearchParameterStatus.Supported);
var resourceTypeSearchParamHashMap = new Dictionary<string, string>
{
{ "Appointment", "appointmentHash" },
{ "AppointmentResponse", "appointmentResponseHash" },
};

ReindexJobRecord job = CreateReindexJobRecord(paramHashMap: resourceTypeSearchParamHashMap);

Expand Down Expand Up @@ -543,5 +544,10 @@ private ReindexJobRecord CreateReindexJobRecord(uint maxResourcePerQuery = 100,

return new ReindexJobRecord(paramHashMap, new List<string>(), searchParameterTypes, searchParameterResourceTypes: resourceTypes, maxiumumConcurrency: 1, maxResourcePerQuery);
}

private async Task SetSearchParameterStatus(IReadOnlyCollection<string> searchParameter, SearchParameterStatus status)
{
await _searchParameterStatusmanager.UpdateSearchParameterStatusAsync(searchParameter, status, default);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public async Task GivenNoSupportedSearchParameters_WhenRunningReindexJob_ThenJob
public async Task GivenNoMatchingResources_WhenRunningReindexJob_ThenJobIsCompleted()
{
var searchParam = _supportedSearchParameterDefinitionManager.GetSearchParameter("http://hl7.org/fhir/SearchParameter/Measure-name");
searchParam.IsSearchable = false;
await _searchParameterStatusManager.UpdateSearchParameterStatusAsync(new List<string>() { searchParam.Url.ToString() }, SearchParameterStatus.Supported, default);

var request = new CreateReindexRequest(new List<string>(), new List<string>());
CreateReindexResponse response = await SetUpForReindexing(request);
Expand All @@ -368,12 +368,12 @@ public async Task GivenNoMatchingResources_WhenRunningReindexJob_ThenJobIsComple
{
await PerformReindexingOperation(response, OperationStatus.Completed, cancellationTokenSource);

Assert.True(searchParam.IsSearchable);
var updateSearchParamList = await _searchParameterStatusManager.GetAllSearchParameterStatus(default);
Assert.Equal(SearchParameterStatus.Enabled, updateSearchParamList.Where(sp => sp.Uri.OriginalString == searchParam.Url.OriginalString).First().Status);
}
finally
{
cancellationTokenSource.Cancel();
searchParam.IsSearchable = true;
}
}

Expand Down

0 comments on commit 069eafd

Please sign in to comment.