Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ca7185d
BC-7561 - a bit of cleanup
virgilchiriac Jan 15, 2025
dba8d83
BC-7561 - improve logic for bulk deletion
virgilchiriac Jan 20, 2025
a364574
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 20, 2025
ee088b5
fix api tets and change sorting
virgilchiriac Jan 20, 2025
e3b952c
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 20, 2025
fc5ce93
Fix some tests
virgilchiriac Jan 21, 2025
da3d694
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 21, 2025
3772528
split pending and failed into a separate job
virgilchiriac Jan 22, 2025
42127e2
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 22, 2025
7b8eccf
implement type casting for command flags
virgilchiriac Jan 22, 2025
9745671
fix linter / remove tests
virgilchiriac Jan 22, 2025
26444f0
unset db debug mode
virgilchiriac Jan 22, 2025
d10659a
undo flag in console
virgilchiriac Jan 22, 2025
e8ab582
fix test
virgilchiriac Jan 23, 2025
eb96b3f
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 23, 2025
8b8e624
fix tests
virgilchiriac Jan 23, 2025
3cc6551
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 23, 2025
86bfdcf
add cronjob
virgilchiriac Jan 23, 2025
51ea68e
fix test
virgilchiriac Jan 23, 2025
3114233
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 23, 2025
ec23c1d
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 24, 2025
e80920a
improve test cov
virgilchiriac Jan 24, 2025
2ec2d7d
Merge branch 'BC-7561-batch-delete-fix' of https://github.com/hpi-sch…
virgilchiriac Jan 24, 2025
a42c73b
fixes from revviews
virgilchiriac Jan 24, 2025
e216fc9
fix query
virgilchiriac Jan 24, 2025
92dc292
hacky type casting for console args
virgilchiriac Jan 27, 2025
e73ff3a
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 27, 2025
d070847
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 27, 2025
88906bd
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 27, 2025
a7e13c7
undo package.json command
virgilchiriac Jan 27, 2025
3d25423
Merge branch 'BC-7561-batch-delete-fix' of https://github.com/hpi-sch…
virgilchiriac Jan 27, 2025
c40c290
throttle down max number of processing requests in batch
virgilchiriac Jan 28, 2025
e6e8051
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 28, 2025
6adc016
fix max concurency / limit and some tests
virgilchiriac Jan 29, 2025
90dc237
Merge branch 'BC-7561-batch-delete-fix' of https://github.com/hpi-sch…
virgilchiriac Jan 29, 2025
39a1d67
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Jan 29, 2025
b2a607b
optimization
virgilchiriac Jan 29, 2025
b6d183a
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Feb 3, 2025
490e35b
Merge branch 'BC-7561-batch-delete-fix' of https://github.com/hpi-sch…
virgilchiriac Feb 3, 2025
4ebe5f8
fix test
virgilchiriac Feb 4, 2025
240b55e
fix pending count query
virgilchiriac Feb 5, 2025
bc08140
improve tests readability
virgilchiriac Feb 5, 2025
634705f
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Feb 5, 2025
cc1dd23
Merge branch 'main' into BC-7561-batch-delete-fix
virgilchiriac Feb 5, 2025
caba67f
fix linter
virgilchiriac Feb 5, 2025
1e62200
Merge branch 'BC-7561-batch-delete-fix' of https://github.com/hpi-sch…
virgilchiriac Feb 5, 2025
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
Prev Previous commit
Next Next commit
hacky type casting for console args
  • Loading branch information
virgilchiriac committed Jan 27, 2025
commit 92dc292ab903fc0812c5414c3a65249fb711c570
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import { DeletionExecutionConsole } from './deletion-execution.console';
import { DeletionExecutionTriggerResultBuilder, TriggerDeletionExecutionOptionsBuilder } from './builder';
import { DeletionExecutionUc } from './uc';
import { DeletionConsoleModule } from './deletion-console.app.module';
import { TriggerDeletionExecutionOptions } from './interface';

describe(DeletionExecutionConsole.name, () => {
let module: TestingModule;
@@ -92,5 +93,29 @@ describe(DeletionExecutionConsole.name, () => {
expect(spy).toHaveBeenCalledWith(err);
});
});

describe('when runFailed is given as string "true"', () => {
it('should convert runFailed to boolean', async () => {
const options = { limit: 1000, runFailed: 'true' } as unknown as TriggerDeletionExecutionOptions;

const spy = jest.spyOn(deletionExecutionUc, 'triggerDeletionExecution').mockResolvedValueOnce(undefined);

await console.triggerDeletionExecution(options);

expect(spy).toHaveBeenCalledWith(1000, true);
});
});

describe('when limit is a string "5"', () => {
it('should convert limit to number', async () => {
const options = { limit: '5', runFailed: false } as unknown as TriggerDeletionExecutionOptions;

const spy = jest.spyOn(deletionExecutionUc, 'triggerDeletionExecution').mockResolvedValueOnce(undefined);

await console.triggerDeletionExecution(options);

expect(spy).toHaveBeenCalledWith(5, false);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -14,26 +14,34 @@ export class DeletionExecutionConsole {
options: [
{
flags: '-l, --limit <value>',
/* istanbul ignore next */
fn: (value: string) => (value ? Number(value) : undefined), // NOSONAR
// TODO implemnt fn with proper command testing
// fn: (value: string) => (value ? Number(value) : undefined),
description: 'Limit of the requested deletion executions that should be performed.',
required: false,
},
{
flags: '-f, --runFailed <value>',
/* istanbul ignore next */
fn: (value: string) => /^(true|yes|1)$/i.test(value), // NOSONAR
// TODO implemnt fn with proper command testing
// fn: (value: string) => /^(true|yes|1)$/i.test(value),
description: 'Limit of the requested deletion executions that should be performed.',
required: false,
},
],
})
async triggerDeletionExecution(options: TriggerDeletionExecutionOptions): Promise<void> {
public async triggerDeletionExecution(options: TriggerDeletionExecutionOptions): Promise<void> {
// Try to trigger the deletion execution(s) via Deletion API client,
// return successful status in case of a success, otherwise return
// a result with a failure status and a proper error message.
let result: DeletionExecutionTriggerResult;

if (typeof options.limit === 'string') {
options.limit = Number(options.limit);
}

if (typeof options.runFailed === 'string') {
options.runFailed = /^(true|yes|1)$/i.test(options.runFailed);
}

try {
await this.deletionExecutionUc.triggerDeletionExecution(options.limit, options.runFailed);
result = DeletionExecutionTriggerResultBuilder.buildSuccess();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface TriggerDeletionExecutionOptions {
limit: number;
runFailed: boolean;
limit: string | number;
runFailed: string | boolean;
}

Unchanged files with check annotations Beta

ENV NODE_ENV=production
ENV NO_COLOR="true"
CMD npm run start

Check warning on line 27 in Dockerfile

GitHub Actions / build_and_push

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
ARG BASE_IMAGE
FROM $BASE_IMAGE

Check warning on line 2 in Dockerfile.filepreview

GitHub Actions / build_and_push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $BASE_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
RUN apk add --no-cache imagemagick imagemagick-heic imagemagick-jpeg imagemagick-pdf imagemagick-raw imagemagick-svg imagemagick-tiff imagemagick-webp
// application imports
import { LegacyLogger, Logger } from '@core/logger';
import { RedisIoAdapter } from '@infra/socketio';

Check warning on line 10 in apps/server/src/apps/board-collaboration.app.ts

GitHub Actions / nest_lint

'@infra/socketio' import is restricted from being used by a pattern. apps-modules may NOT import from apps, @infra, @shared, or migrations
import { BoardCollaborationModule } from '@modules/board/board-collaboration.app.module';
import { ExpressAdapter } from '@nestjs/platform-express';
import { SwaggerDocumentOptions } from '@nestjs/swagger';
import { DeletionConsoleModule } from '@modules/deletion-console/deletion-console.app.module';
import { BootstrapConsole } from 'nestjs-console';
async function run() {

Check warning on line 5 in apps/server/src/apps/deletion-console.app.ts

GitHub Actions / nest_lint

Missing return type on function
const bootstrap = new BootstrapConsole({
module: DeletionConsoleModule,
useDecorators: true,
// application imports
import { LegacyLogger } from '@core/logger';
import { FilesStorageApiModule } from '@modules/files-storage/files-storage-api.app.module';
import { API_VERSION_PATH } from '@modules/files-storage/files-storage.const';

Check warning on line 13 in apps/server/src/apps/files-storage.app.ts

GitHub Actions / nest_lint

'@modules/files-storage/files-storage.const' import is restricted from being used by a pattern. Do not deep import from a module
import { SwaggerDocumentOptions } from '@nestjs/swagger';
import { enableOpenApiDocs } from './helpers';
import { createRequestLoggerMiddleware } from './helpers/request-logger-middleware';
/* istanbul ignore file */
/* eslint-disable no-console */
import { NestFactory } from '@nestjs/core';

Check warning on line 3 in apps/server/src/apps/h5p-editor.app.ts

GitHub Actions / nest_lint

Filename 'h5p-editor.app.ts' does not match kebabcase
import { ExpressAdapter } from '@nestjs/platform-express';
import express from 'express';
/* istanbul ignore file */
/* eslint-disable no-console */
import { LegacyLogger } from '@core/logger';

Check warning on line 3 in apps/server/src/apps/h5p-library-management.app.ts

GitHub Actions / nest_lint

Filename 'h5p-library-management.app.ts' does not match kebabcase
import { H5PLibraryManagementService } from '@modules/h5p-library-management';
import { H5PLibraryManagementModule } from '@modules/h5p-library-management/h5p-library-management.app.module';
import { NestFactory } from '@nestjs/core';
export class AppStartLoggable implements Loggable {
constructor(private readonly info: AppStartInfo) {}
getLogMessage(): LogMessage {

Check warning on line 13 in apps/server/src/apps/helpers/app-start-loggable.ts

GitHub Actions / nest_lint

Missing accessibility modifier on method definition getLogMessage
const data: LogMessageData = { appName: this.info.appName };
if (this.info.port !== undefined) {
export class PrometheusMetricsSetupStateLoggable implements Loggable {
constructor(private readonly state: PrometheusMetricsSetupState) {}
getLogMessage(): LogMessage {

Check warning on line 22 in apps/server/src/apps/helpers/metrics/prometheus-metrics.ts

GitHub Actions / nest_lint

Missing accessibility modifier on method definition getLogMessage
return {
message: 'Setting up Prometheus metrics...',
data: {
}
}
export const addPrometheusMetricsMiddlewaresIfEnabled = (logger: Logger, app: Express) => {

Check warning on line 32 in apps/server/src/apps/helpers/metrics/prometheus-metrics.ts

GitHub Actions / nest_lint

Missing return type on function
if (!PrometheusMetricsConfig.instance.isEnabled) {
logger.debug(
new PrometheusMetricsSetupStateLoggable(
);
};
export const createAndStartPrometheusMetricsAppIfEnabled = (logger: Logger) => {

Check warning on line 52 in apps/server/src/apps/helpers/metrics/prometheus-metrics.ts

GitHub Actions / nest_lint

Missing return type on function
if (!PrometheusMetricsConfig.instance.isEnabled) {
logger.debug(
new PrometheusMetricsSetupStateLoggable(PrometheusMetricsSetupState.FEATURE_DISABLED_APP_WILL_NOT_BE_CREATED)
this._collectMetricsRouteMetrics = Configuration.get('PROMETHEUS_METRICS_COLLECT_METRICS_ROUTE_METRICS') as boolean;
}
public static get instance() {

Check warning on line 44 in apps/server/src/apps/helpers/metrics/prometheus/config.ts

GitHub Actions / nest_lint

Public accessibility modifier on get property accessor instance
if (this._instance === undefined) {
this._instance = new this();
}