search refactoring

This commit is contained in:
sbwalker
2024-07-06 07:58:04 -04:00
parent e321998b85
commit 5b46dd7293
18 changed files with 248 additions and 406 deletions

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using Oqtane.Models;
namespace Oqtane.Services
{
public interface ISearchIndexManager
{
int Priority { get; }
string Name { get; }
bool IsIndexEnabled(int siteId);
int IndexContent(int siteId, DateTime? startTime, Action<List<SearchContent>> processSearchContent, Action<string> handleError);
}
}

View File

@ -1,5 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oqtane.Models;
@ -8,7 +6,7 @@ namespace Oqtane.Services
{
public interface ISearchService
{
void IndexContent(int siteId, DateTime? startTime, Action<string> logNote, Action<string> handleError);
Task SaveSearchContentAsync(List<SearchContent> searchContents);
Task<SearchResults> SearchAsync(SearchQuery searchQuery);
}

View File

@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oqtane.Models;
namespace Oqtane.Interfaces
{
public interface ISearchable
{
public List<SearchContent> GetSearchContents(PageModule pageModule, DateTime startTime);
public Task<List<SearchContent>> GetSearchContentsAsync(PageModule pageModule, DateTime lastIndexedOn);
}
}

View File

@ -42,6 +42,9 @@ namespace Oqtane.Models
[NotMapped]
public int TenantId { get; set; }
[NotMapped]
public bool IsDeleted { get; set; }
// constructors
public SearchContent() { }

View File

@ -81,7 +81,9 @@ namespace Oqtane.Shared
public const string DefaultSearchProviderName = "Database";
public const string SearchPageIdPropertyName = "PageId";
public const string SearchModuleIdPropertyName = "ModuleId";
public static readonly string[] InternalPagePaths = { "login", "register", "reset", "404" };
// Obsolete constants
const string RoleObsoleteMessage = "Use the corresponding member from Oqtane.Shared.RoleNames";

View File

@ -560,7 +560,7 @@ namespace Oqtane.Shared
return (localDateTime?.Date, localTime);
}
public static bool IsPageModuleVisible(DateTime? effectiveDate, DateTime? expiryDate)
public static bool IsEffectiveOrExpired(DateTime? effectiveDate, DateTime? expiryDate)
{
DateTime currentUtcTime = DateTime.UtcNow;
@ -582,6 +582,7 @@ namespace Oqtane.Shared
return true;
}
}
public static bool ValidateEffectiveExpiryDates(DateTime? effectiveDate, DateTime? expiryDate)
{
// Treat DateTime.MinValue as null
@ -609,6 +610,7 @@ namespace Oqtane.Shared
return true;
}
}
[Obsolete("ContentUrl(Alias alias, int fileId) is deprecated. Use FileUrl(Alias alias, int fileId) instead.", false)]
public static string ContentUrl(Alias alias, int fileId)
{
@ -623,5 +625,12 @@ namespace Oqtane.Shared
return $"{alias?.BaseUrl}{aliasUrl}{Constants.ContentUrl}{fileId}{method}";
}
[Obsolete("IsPageModuleVisible(DateTime?, DateTime?) is deprecated. Use IsEffectiveOrExpired(DateTime?, DateTime?) instead.", false)]
public static bool IsPageModuleVisible(DateTime? effectiveDate, DateTime? expiryDate)
{
return IsEffectiveOrExpired(effectiveDate, expiryDate);
}
}
}