Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main from develop #481

Merged
merged 4 commits into from
Feb 26, 2025
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@types/jsonwebtoken": "^9.0.8",
"@types/mime-types": "^2.1.4",
"@types/mocha": "^10.0.10",
"@types/node": "^20.17.17",
"@types/node": "^20.17.19",
"@types/node-cron": "^3.0.11",
"@types/nodemailer": "^6.4.17",
"@types/sinon": "^17.0.3",
Expand Down
7 changes: 4 additions & 3 deletions src/controller/banner-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
*/

/**
* This is the module page of banner-controller.
*
* @module banners
* @module Banners
*/

import { Response } from 'express';
Expand All @@ -37,6 +35,9 @@ import FileService from '../service/file-service';
import { BANNER_IMAGE_LOCATION } from '../files/storage';
import { parseRequestPagination } from '../helpers/pagination';

/**
* Controller for managing all routes related to the `banner` entity.
*/
export default class BannerController extends BaseController {
private logger: Logger = log4js.getLogger('BannerController');

Expand Down
5 changes: 2 additions & 3 deletions src/controller/request/banner-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
*/

/**
* This is the module page of the banner-request.
*
* @module banners
* @module Banners
*/

/**
* API Request for creating a `banner` entity.
* @typedef {object} BannerRequest
* @property {string} name - Name/label of the banner
* @property {number} duration - How long the banner should be shown (in seconds)
Expand Down
6 changes: 3 additions & 3 deletions src/controller/response/banner-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
*/

/**
* This is the module page of the banner-response.
*
* @module banners
* @module Banners
*/

import BaseResponse from './base-response';
import { PaginationResult } from '../../helpers/pagination';

/**
* API Response for the `banner` entity.
* @typedef {allOf|BaseResponse} BannerResponse
* @property {string} name.required - Name/label of the banner
* @property {string} image - Location of the image
Expand All @@ -46,6 +45,7 @@ export interface BannerResponse extends BaseResponse {
}

/**
* Paginated API Response for the `banner` entity.
* @typedef {object} PaginatedBannerResponse
* @property {PaginationResult} _pagination - Pagination metadata
* @property {Array<BannerResponse>} records - Returned banners
Expand Down
2 changes: 2 additions & 0 deletions src/controller/response/debtor-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ export interface FineResponse extends BaseResponse {
* @typedef {allOf|BaseResponse} BaseFineHandoutEventResponse
* @property {string} referenceDate.required - Reference date of fines
* @property {BaseUserResponse} createdBy.required - User that handed out the fines
* @property {number} count.required - The amount of fines that were handed out
*/
export interface BaseFineHandoutEventResponse extends BaseResponse {
referenceDate: string;
createdBy: BaseUserResponse;
count: number;
}

/**
Expand Down
12 changes: 10 additions & 2 deletions src/entity/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@
*/

/**
* This is the module page of banner.
* `banners` are used to manage promotional material within SudoSOS, commonly displayed on the point of sale.
* They can be configured with a duration, activation status, and start/end dates to control their visibility.
*
* @module banners
* ### Usage
* - Banners can be created, updated, or deleted by admins.
* - Active banners can be retrieved without authentication.
*
* For API interactions, refer to the [Swagger Documentation](https://sudosos.gewis.nl/api/api-docs/#/banners).
*
* @module Banners
* @mergeTarget
*/

Expand All @@ -32,6 +39,7 @@ import BaseEntity from './base-entity';
import BannerImage from './file/banner-image';

/**
* TypeORM entity for the `banners` table.
* @typedef {BaseEntity} Banner
* @property {string} name - Name/label of the banner.
* @property {integer} duration - How long the banner should be shown (in seconds).
Expand Down
6 changes: 3 additions & 3 deletions src/entity/file/banner-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
*/

/**
* This is the module page of banner-image.
*
* @module banners
* @module Banners
*/

import { Entity } from 'typeorm';
import BaseFile from './base-file';

/**
* TypeORM entity for banner images.
* Note that the image itself is stored in the file system, but the table is used to store the location of the image.
* @typedef {BaseFile} BannerImage
*/
@Entity()
Expand Down
10 changes: 7 additions & 3 deletions src/service/banner-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
*/

/**
* This is the module page of the banner-service.
*
* @module banners
* @module Banners
*/

import { FindManyOptions } from 'typeorm';
Expand All @@ -32,11 +30,17 @@ import QueryFilter, { FilterMapping } from '../helpers/query-filter';
import FileService from './file-service';
import { PaginationParameters } from '../helpers/pagination';

/**
* Filter parameters for the `banner` entity.
*/
export interface BannerFilterParameters {
bannerId?: number,
active?: boolean,
}

/**
* Service class for the `banner` entity,
*/
export default class BannerService {
/**
* Verifies whether the banner request translates to a valid banner object
Expand Down
2 changes: 2 additions & 0 deletions src/service/debtor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default class DebtorService extends WithManager {
updatedAt: e.updatedAt.toISOString(),
referenceDate: e.referenceDate.toISOString(),
createdBy: parseUserToBaseResponse(e.createdBy, false),
count: e.fines ? e.fines.length : 0,
};
}

Expand Down Expand Up @@ -269,6 +270,7 @@ export default class DebtorService extends WithManager {
referenceDate: fineHandoutEvent1.referenceDate.toISOString(),
createdBy: parseUserToBaseResponse(fineHandoutEvent1.createdBy, false),
fines: fines1.map((f) => DebtorService.asFineResponse(f)),
count: fines1.length,
};
}

Expand Down
6 changes: 1 addition & 5 deletions src/service/transaction-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +667,8 @@ export default class TransactionService extends WithManager {

await transaction.save();

// save the transaction and invalidate user balance cache
const savedTransaction = await this.asTransactionResponse(transaction);
await TransactionService.invalidateBalanceCache(savedTransaction);

// save transaction and return response
return savedTransaction;
return this.asTransactionResponse(transaction);
}

/**
Expand Down
Loading