Skip to content

Commit

Permalink
Chore: code cleanup, update openapi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
MauritsioRK committed May 7, 2020
1 parent 5080850 commit 9ead3c8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lib/application/usecases/log/GetLogUseCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ const {
} = require('../../../database');

/**
* GetLogsUseCase
* GetLogUseCase
*/
class GetLogsUseCase extends IUseCase {
class GetLogUseCase extends IUseCase {
/**
* Executes this use case.
*
* @param {Number} id ID of the entity to retrieve.
* @returns {Promise} Promise object represents the result of this use case.
*/
async execute(id) {
return TransactionHelper.provide(() => LogRepository.find(id));
return TransactionHelper.provide(() => LogRepository.findOneById(id));
}
}

module.exports = GetLogsUseCase;
module.exports = GetLogUseCase;
4 changes: 2 additions & 2 deletions lib/database/repositories/LogRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class LogRepository extends ILogRepository {
* @param {Number} id ID primary key of the entity to find.
* @returns {Promise|Null} Promise object representing the full mock data
*/
async find(id) {
async findOneById(id) {
const result = await Log.findByPk(id);
return result ? [LogAdapter.toEntity(result)] : null;
return result ? LogAdapter.toEntity(result) : null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/public/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class Model extends Observable {
this.logs.fetchAllLogs();
break;
case 'entry':
this.logs.fetchLog(this.router.params.id);
this.logs.fetchOneLog(this.router.params.id);
break;
default:
this.router.go('?page=home');
Expand Down
6 changes: 3 additions & 3 deletions lib/public/views/Logs/Logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ export default class Overview extends Observable {
* @param {Number} id The ID of the log to be found
* @returns {undefined} Injects the data object with the response data
*/
async fetchLog(id) {
async fetchOneLog(id) {
// Do not call this endpoint again if we already have all the logs
if (this.data.length < 1) {
if (this.data && this.data.length < 1) {
const response = await fetchClient(`/api/logs/${id}`, { method: 'GET' });
const result = await response.json();

if (result.data) {
this.data = result.data;
this.data = [result.data];
this.error = false;
} else {
this.error = true;
Expand Down
5 changes: 4 additions & 1 deletion spec/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ components:
type: object
properties:
data:
type: array
type:
oneOf:
- array
- object
required:
- data
DeployInformation:
Expand Down

0 comments on commit 9ead3c8

Please sign in to comment.