Skip to content

Commit

Permalink
Fix number of terms displayed in logs and Reporter module instantiati…
Browse files Browse the repository at this point in the history
…on (#1088)
  • Loading branch information
Ndpnt authored Jun 7, 2024
2 parents c016e96 + b6db232 commit 5712ca9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)._
Expand Down
2 changes: 1 addition & 1 deletion src/archivist/services/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
6 changes: 6 additions & 0 deletions src/archivist/services/service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});
});
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { createRequire } from 'module';

import config from 'config';
import cron from 'croner';
import cronstrue from 'cronstrue';
Expand All @@ -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'),
Expand All @@ -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 => {
Expand Down Expand Up @@ -50,7 +56,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'));

Expand Down

0 comments on commit 5712ca9

Please sign in to comment.