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
19 changes: 13 additions & 6 deletions src/modules/ie-objects/elasticsearch/queryBuilder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ describe('QueryBuilder', () => {
);
});

it('Should produce a terms query on dcterms_rights_statement when freely-reusable is selected', () => {
it('Should produce a bool/should query on dcterms_rights_statement and reuse_category when freely-reusable is selected', () => {
const queryObject = QueryBuilder.build(
{
page: 1,
Expand All @@ -613,12 +613,13 @@ describe('QueryBuilder', () => {
);
const queryString = JSON.stringify(queryObject);
expect(queryString).toContain('dcterms_rights_statement');
expect(queryString).toContain('reuse_category');
expect(queryString).toContain('https://creativecommons.org/publicdomain/mark/1.0/');
// Should not include URIs from other categories
expect(queryString).not.toContain('https://rightsstatements.org/page/InC/1.0/');
});

it('Should apply reusability filter using dcterms rights statements for all 3 reusability categories', () => {
it('Should apply reusability filter using dcterms rights statements and reuse_category for all 3 reusability categories', () => {
const queryObject = QueryBuilder.build(
{
page: 1,
Expand All @@ -640,7 +641,9 @@ describe('QueryBuilder', () => {
const queryString = JSON.stringify(queryObject);
expect(queryString).toContain('https://creativecommons.org/publicdomain/mark/1.0/');
expect(queryString).toContain('https://rightsstatements.org/page/UND/1.0/');
expect(queryString).toContain('REUSABILITY_DCTERMS_RIGHTS_STATEMENT');
expect(queryString).toContain('REUSABILITY_DCTERMS_RIGHTS_STATEMENT_NEWSPAPERS');
expect(queryString).toContain('REUSABILITY_REUSE_CATEGORY_AUDIO_VIDEO');
expect(queryString).toContain('reuse_category');
});

it('Should apply reusability filters in the public limited metadata branch', () => {
Expand All @@ -661,7 +664,9 @@ describe('QueryBuilder', () => {

const publicLimitedBranch = JSON.stringify(queryObject.query.bool.should[0]);
expect(publicLimitedBranch).toContain('PUBLIC-METDATA_LTD');
expect(publicLimitedBranch).toContain('REUSABILITY_DCTERMS_RIGHTS_STATEMENT');
expect(publicLimitedBranch).toContain('REUSABILITY_DCTERMS_RIGHTS_STATEMENT_NEWSPAPERS');
expect(publicLimitedBranch).toContain('REUSABILITY_REUSE_CATEGORY_AUDIO_VIDEO');
expect(publicLimitedBranch).toContain('reuse_category');
expect(publicLimitedBranch).toContain('https://rightsstatements.org/page/UND/1.0/');
});

Expand All @@ -684,7 +689,7 @@ describe('QueryBuilder', () => {
expect(queryString).not.toContain('dcterms_rights_statement');
});

it('Should apply dcterms rights statements for reusable-with-conditions category', () => {
it('Should apply dcterms rights statements and reuse_category for reusable-with-conditions category', () => {
const queryObject = QueryBuilder.build(
{
page: 1,
Expand All @@ -701,7 +706,9 @@ describe('QueryBuilder', () => {
);

const queryString = JSON.stringify(queryObject);
expect(queryString).toContain('REUSABILITY_DCTERMS_RIGHTS_STATEMENT');
expect(queryString).toContain('REUSABILITY_DCTERMS_RIGHTS_STATEMENT_NEWSPAPERS');
expect(queryString).toContain('REUSABILITY_REUSE_CATEGORY_AUDIO_VIDEO');
expect(queryString).toContain('reuse_category');
expect(queryString).toContain('https://rightsstatements.org/page/NoC-CR/1.0/');
});

Expand Down
24 changes: 17 additions & 7 deletions src/modules/ie-objects/elasticsearch/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import jsep from 'jsep';
import { clamp, compact, forEach, isArray, isEmpty, isNil, uniq } from 'lodash';

import { IeObjectsQueryDto, SearchFilter } from '../dto/ie-objects.dto';
import {
buildFreeTextFilter,
convertNodeToEsQueryFilterObjects,
} from '../helpers/convert-node-to-es-query-filter-objects';
import { buildFreeTextFilter, convertNodeToEsQueryFilterObjects, } from '../helpers/convert-node-to-es-query-filter-objects';
import { encodeSearchterm } from '../helpers/encode-search-term';
Comment thread
bertyhell marked this conversation as resolved.
import { IeObjectLicense } from '../ie-objects.types';

Expand Down Expand Up @@ -661,9 +658,22 @@ export class QueryBuilder {
const reusabilityQueries = [
rightsStatementUris.length
? {
terms: {
_name: 'REUSABILITY_DCTERMS_RIGHTS_STATEMENT',
dcterms_rights_statement: rightsStatementUris,
bool: {
should: [
{
terms: {
_name: 'REUSABILITY_DCTERMS_RIGHTS_STATEMENT_NEWSPAPERS',
dcterms_rights_statement: rightsStatementUris,
},
},
{
terms: {
_name: 'REUSABILITY_REUSE_CATEGORY_AUDIO_VIDEO',
'reuse_category.id': rightsStatementUris,
},
},
Comment thread
bertyhell marked this conversation as resolved.
],
minimum_should_match: 1,
},
}
: null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
import { parse } from 'node:path';
import { AssetsService, DataService, Locale, StillsObjectType, VideoStillsService, } from '@meemoo/admin-core-api';
import { BadRequestException, Injectable, InternalServerErrorException, NotFoundException, } from '@nestjs/common';
import {
AssetsService,
DataService,
Locale,
StillsObjectType,
VideoStillsService,
} from '@meemoo/admin-core-api';
import {
BadRequestException,
Injectable,
InternalServerErrorException,
NotFoundException,
} from '@nestjs/common';
import { type IPagination, Pagination } from '@studiohyperdrive/pagination';
import { mapLimit } from 'blend-promise-utils';
import { compact, groupBy, intersection, isArray, isEmpty, isNil, kebabCase, noop, set, } from 'lodash';
import {
compact,
groupBy,
intersection,
isArray,
isEmpty,
isNil,
kebabCase,
noop,
set,
} from 'lodash';

import {
CreateMaterialRequestDto,
Expand Down
7 changes: 6 additions & 1 deletion src/modules/organisations/mocks/organisations.mocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ContactPointType, type GqlOrganisation, type Organisation, PostalAddressType, } from '../organisations.types';
import {
ContactPointType,
type GqlOrganisation,
type Organisation,
PostalAddressType,
} from '../organisations.types';

import { IeObjectSector } from '~modules/ie-objects/ie-objects.types';

Expand Down
7 changes: 6 additions & 1 deletion src/modules/sitemap/services/sitemap.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { AssetsService, ContentPagesService, DataService, DbContentPage, } from '@meemoo/admin-core-api';
import {
AssetsService,
ContentPagesService,
DataService,
DbContentPage,
} from '@meemoo/admin-core-api';
import { Injectable, InternalServerErrorException } from '@nestjs/common';
import { format } from 'date-fns';
import { compact, kebabCase, uniqBy } from 'lodash';
Expand Down
15 changes: 13 additions & 2 deletions src/modules/users/services/users.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { convertUserInfoToCommonUser, DataService, UserInfoType } from '@meemoo/admin-core-api';
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
import { AvoAuthIdpType, AvoUserCommonUser, AvoUserHetArchiefUser, PermissionName, } from '@viaa/avo2-types';
import {
AvoAuthIdpType,
AvoUserCommonUser,
AvoUserHetArchiefUser,
PermissionName,
} from '@viaa/avo2-types';

import {
GetUserByEmailDocument,
Expand Down Expand Up @@ -35,7 +40,13 @@ import { getOrganisationAddress } from '~modules/organisations/helpers/get-organ
import { customError } from '~shared/helpers/custom-error';
import type { UpdateResponse } from '~shared/types/types';
import { CreateOrUpdateUserDto, UpdateAcceptedTosDto, UpdateUserLangDto } from '../dto/users.dto';
import { type GqlPermissionData, type GqlUser, GroupIdToName, type GroupName, type User, } from '../types';
import {
type GqlPermissionData,
type GqlUser,
GroupIdToName,
type GroupName,
type User,
} from '../types';

@Injectable()
export class UsersService {
Expand Down