From aebf1cc946f319554e1c83859d8f6aeede494032 Mon Sep 17 00:00:00 2001 From: Nicolas Dupont Date: Fri, 7 Jun 2024 09:22:25 +0200 Subject: [PATCH 1/4] Fix the number of terms displayed in logs --- src/archivist/services/service.js | 2 +- src/archivist/services/service.test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/archivist/services/service.js b/src/archivist/services/service.js index c4482c573..950574a3e 100644 --- a/src/archivist/services/service.js +++ b/src/archivist/services/service.js @@ -31,7 +31,7 @@ export default class Service { getTermsTypes(termsTypes) { let result = Object.keys(this.terms); - if (termsTypes) { + if (termsTypes?.length) { result = result.filter(item => termsTypes.includes(item)); } diff --git a/src/archivist/services/service.test.js b/src/archivist/services/service.test.js index 1a9e81b37..3516c4d58 100644 --- a/src/archivist/services/service.test.js +++ b/src/archivist/services/service.test.js @@ -175,6 +175,12 @@ describe('Service', () => { it('returns the number of terms matching the provided terms types', () => { expect(subject.getNumberOfTerms([ TERMS_OF_SERVICE_TYPE, IMPRINT_TYPE ])).to.equal(1); }); + + context('when the provided filter is empty', () => { + it('returns the number of all terms types', () => { + expect(subject.getNumberOfTerms([])).to.equal(2); + }); + }); }); }); }); From 96af020ce0eca50d285238e6e6b03af1d5b997b3 Mon Sep 17 00:00:00 2001 From: Nicolas Dupont Date: Fri, 7 Jun 2024 09:23:21 +0200 Subject: [PATCH 2/4] Fix Reporter module instantiation --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index bd0b7b9b7..7a8ee533a 100644 --- a/src/index.js +++ b/src/index.js @@ -50,7 +50,7 @@ export default async function track({ services, types, extractOnly, schedule }) } if (process.env.OTA_ENGINE_GITHUB_TOKEN) { - if (config.has('reporter.githubIssues.repositories.declarations')) { + if (config.has('@opentermsarchive/engine.reporter.githubIssues.repositories.declarations')) { try { const reporter = new Reporter(config.get('@opentermsarchive/engine.reporter')); From 2d53c440fe9d6511799cb4bd6f198f7cf9fa9595 Mon Sep 17 00:00:00 2001 From: Nicolas Dupont Date: Fri, 7 Jun 2024 09:26:24 +0200 Subject: [PATCH 3/4] Display engine version in logs Given the numerous collections with varying engine versions, having this information when analyzing the logs helps us identify potential bugs more effectively --- src/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7a8ee533a..2083e1802 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,5 @@ +import { createRequire } from 'module'; + import config from 'config'; import cron from 'croner'; import cronstrue from 'cronstrue'; @@ -7,6 +9,8 @@ import logger from './logger/index.js'; import Notifier from './notifier/index.js'; import Reporter from './reporter/index.js'; +const require = createRequire(import.meta.url); + export default async function track({ services, types, extractOnly, schedule }) { const archivist = new Archivist({ recorderConfig: config.get('@opentermsarchive/engine.recorder'), @@ -17,7 +21,9 @@ export default async function track({ services, types, extractOnly, schedule }) await archivist.initialize(); - logger.info('Start Open Terms Archive\n'); + const { version } = require('../package.json'); + + logger.info(`Start Open Terms Archive engine v${version}\n`); if (services?.length) { services = services.filter(serviceId => { From b6db2321a3bd11db6abd1ac26e3ae01c06caecd8 Mon Sep 17 00:00:00 2001 From: Nicolas Dupont Date: Fri, 7 Jun 2024 09:29:30 +0200 Subject: [PATCH 4/4] Add changelog entries --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da70525b2..c2d47329e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased [patch] + +> Development of this release was supported by the [French Ministry for Foreign Affairs](https://www.diplomatie.gouv.fr/fr/politique-etrangere-de-la-france/diplomatie-numerique/) through its ministerial [State Startups incubator](https://beta.gouv.fr/startups/open-terms-archive.html) under the aegis of the Ambassador for Digital Affairs. + +### Fixed + +- Fix the number of terms displayed in logs +- Fix Reporter module instantiation + +### Added + +- Display engine version in logs + ## 2.2.0 - 2024-06-05 _Full changeset and discussions: [#1087](https://github.com/OpenTermsArchive/engine/pull/1087)._