Added upper limit to browse by date

This commit is contained in:
Michael Spalti
2023-03-28 13:18:34 -07:00
parent 1ddeeed081
commit 5b33c49ccc
3 changed files with 66 additions and 29 deletions

View File

@@ -22,6 +22,7 @@ import { BrowseEntrySearchOptions } from './browse-entry-search-options.model';
import { HrefOnlyDataService } from '../data/href-only-data.service';
import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
import { BrowseDefinitionDataService } from './browse-definition-data.service';
import { SortDirection } from '../cache/models/sort-options.model';
export const BROWSE_LINKS_TO_FOLLOW: FollowLinkConfig<BrowseEntry | Item>[] = [
@@ -160,8 +161,9 @@ export class BrowseService {
* Get the first item for a metadata definition in an optional scope
* @param definition
* @param scope
* @param sortDirection optional sort parameter
*/
getFirstItemFor(definition: string, scope?: string): Observable<RemoteData<Item>> {
getFirstItemFor(definition: string, scope?: string, sortDirection?: SortDirection): Observable<RemoteData<Item>> {
const href$ = this.getBrowseDefinitions().pipe(
getBrowseDefinitionLinks(definition),
hasValueOperator(),
@@ -177,6 +179,9 @@ export class BrowseService {
}
args.push('page=0');
args.push('size=1');
if (sortDirection) {
args.push('sort=default,' + sortDirection);
}
if (isNotEmpty(args)) {
href = new URLCombiner(href, `?${args.join('&')}`).toString();
}