Skip to content

Commit

Permalink
Merge branch 'develop' into feature/3966-database-access-layer-refact…
Browse files Browse the repository at this point in the history
…oring
  • Loading branch information
ihar-tsykala authored Aug 11, 2024
2 parents 87a5fa5 + b9076c2 commit 37f5828
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 96 deletions.
1 change: 1 addition & 0 deletions Methodology Library/CDM/Work In Progress/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Methodology Library/Verra/Work In Progress/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 5 additions & 1 deletion common/src/helpers/db-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { BaseEntity } from '../models/index.js';
import { DataBaseNamingStrategy } from './db-naming-strategy.js';
import { GridFSBucket } from 'mongodb';

function fixConnectionString(cs: string) {
return /.+\:\/\/.+/.test(cs) ? cs : `mongodb://${cs}`;
}

/**
* Common connection config
*/
Expand All @@ -13,7 +17,7 @@ export const COMMON_CONNECTION_CONFIG: any = {
dbName: (process.env.GUARDIAN_ENV || (process.env.HEDERA_NET !== process.env.PREUSED_HEDERA_NET)) ?
`${process.env.GUARDIAN_ENV}_${process.env.HEDERA_NET}_${process.env.DB_DATABASE}` :
process.env.DB_DATABASE,
clientUrl: `mongodb://${process.env.DB_HOST}`,
clientUrl: fixConnectionString(process.env.DB_HOST),
entities: [
'dist/entity/*.js'
]
Expand Down
4 changes: 4 additions & 0 deletions docs/guardian/global-indexer/indexer-user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ docker compose -f "docker-compose-indexer.yml" up -d --build

Once the above command is successfully executed and all the docker containers are running, Indexer can be launched at [http://localhost:3005](http://localhost:3005)

{% hint style="info" %}
Please note that it would take minimum 6 hours to load complete Indexer data.
{% endhint %}

### Landing page includes following information:

* _Registries_, _Methodologies_, _Total Documents_, _Total Issuance_. All cards are clickable. Also there is an ability to check charts with count and date.
Expand Down
190 changes: 104 additions & 86 deletions docs/guardian/readme/roadmap.md

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions policy-service/src/policy-engine/blocks/documents-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class InterfaceDocumentsSource {
queryParams = {};
}

const {itemsPerPage, page, size, filterByUUID, ...filterIds} = queryParams;
const {itemsPerPage, page, size, filterByUUID, sortDirection, sortField, ...filterIds} = queryParams;

const filterAddons = ref.getFiltersAddons();
const filters = filterAddons.map(addon => {
Expand All @@ -100,11 +100,13 @@ export class InterfaceDocumentsSource {

if (filterIds) {
for (const filterId of Object.keys(filterIds)) {
const filterValue = isNaN(filterIds[filterId]) ? filterIds[filterId] : Number(filterIds[filterId]);

const filter = filterAddons.find((_filter) => {
return (_filter.uuid === filterId) || (_filter.tag === filterId);
});
if (filter) {
await (filter as IPolicyAddonBlock).setFilterState(user, {filterValue: filterIds[filterId]});
await (filter as IPolicyAddonBlock).setFilterState(user, {filterValue});
}
}
}
Expand All @@ -125,8 +127,11 @@ export class InterfaceDocumentsSource {
let paginationData = null;

if (pagination) {
if (itemsPerPage && page) {
await pagination.setState(user, {itemsPerPage, page, size});
if ((!isNaN(page)) && (!isNaN(itemsPerPage))) {
await pagination.setState(user, {
itemsPerPage: parseInt(itemsPerPage, 10),
page: parseInt(page, 10),
});
}

paginationData = await pagination.getState(user);
Expand All @@ -136,8 +141,15 @@ export class InterfaceDocumentsSource {
return addon.blockType === 'historyAddon';
}) as IPolicyAddonBlock;

const enableCommonSorting = ref.options.uiMetaData.enableSorting;
const sortState = this.state[user.id] || {};
const enableCommonSorting = ref.options.uiMetaData.enableSorting || (sortDirection && sortField);
let sortState = this.state[user.id] || {};
if (sortDirection && sortField) {
sortState = {
orderDirection: sortDirection,
orderField: sortField
};
this.state[user.id] = sortState;
}
let data: any = enableCommonSorting
? await this.getDataByAggregationFilters(ref, user, sortState, paginationData, history)
: await ref.getGlobalSources(user, paginationData);
Expand All @@ -158,14 +170,14 @@ export class InterfaceDocumentsSource {
state.document,
history
? history.options.timelineLabelPath ||
'option.status'
'option.status'
: 'option.status'
),
comment: ObjGet(
state.document,
history
? history.options.timelineDescriptionPath ||
'option.comment'
'option.comment'
: 'option.comment'
),
created: state.createDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,28 @@ export function DataSourceBlock(options: Partial<PolicyBlockDecoratorOptions>) {
let totalCount = 0;
let currentPosition = 0;

const _globalFilters = {} as any;
for (const key in globalFilters) {
if (!isNaN(globalFilters[key].$eq)) {
if (!_globalFilters.$or) {
_globalFilters.$or = [];
}
const filter1 = {} as any;
filter1[key] = {eq: String(globalFilters[key].$eq)};
_globalFilters.$or.push(filter1);
const filter2 = {} as any;
filter2[key] = {eq: Number(globalFilters[key].$eq)};
_globalFilters.$or.push(filter2);
} else {
_globalFilters[key] = globalFilters[key];
}
}

const resultsCountArray = [];
const sourceAddons = this.children.filter(c => c.blockClassName === 'SourceAddon');

for (const addon of sourceAddons) {
const resultCount = await addon.getFromSource(user, globalFilters, true);
const resultCount = await addon.getFromSource(user, _globalFilters, true);
totalCount += resultCount;
resultsCountArray.push(resultCount);
}
Expand Down

0 comments on commit 37f5828

Please sign in to comment.