Skip to content
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
16 changes: 14 additions & 2 deletions lib/database/adapters/UserAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@ class UserAdapter {
* @param {Object} databaseObject Object to convert.
* @returns {Object} Converted entity object.
*/
static toEntity({ id, externalId, name }) {
return { id, externalId, name };
static toEntity(databaseObject) {
if (databaseObject) {
return {
id: databaseObject.id,
externalId: databaseObject.externalId,
name: databaseObject.name,
};
} else {
return {
id: 0,
externalId: 0,
name: 'Anonymous',
};
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/

module.exports = {
up: (queryInterface, Sequelize) => queryInterface.changeColumn('logs', 'user_id', {
type: Sequelize.INTEGER,
allowNull: true,
}),

down: (queryInterface, Sequelize) => queryInterface.changeColumn('logs', 'user_id', {
type: Sequelize.INTEGER,
allowNull: false,
}),

};
1 change: 0 additions & 1 deletion lib/database/seeders/20200508094502-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module.exports = {
title: 'Third entry',
subtype: 'announcement',
origin: 'human',
user_id: 1,
text: 'Cake at the particle accelerator!',
parent_log_id: 1,
root_log_id: 1,
Expand Down
3 changes: 1 addition & 2 deletions lib/public/components/Post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const activeFields = (model) => ({
name: 'Tags',
visible: true,
format: (tags) => tags.length > 0 ? tags.map(({ text }) => text).join(', ') : 'None',

},
runs: {
name: 'Runs',
Expand Down Expand Up @@ -115,7 +114,7 @@ const entry = (model, post, index, highlight) => {
h('tbody', Object.entries(postFields)
.map(([key, { name, format, visible }]) => visible && h(`tr#post${index}-${key}`, [
h('td.text-right', { style: 'font-weight: bold' }, `${name}:`),
h('td', post[key] && format ? format(post[key]) : post[key] || 'None'),
h('td', format ? format(post[key]) : post[key]),
]))),
]),
]),
Expand Down
2 changes: 1 addition & 1 deletion lib/usecases/log/CreateLogUseCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CreateLogUseCase {
const { parentLogId, tags } = body;

const log = await TransactionHelper.provide(async () => {
body.userId = dto.session.id;
body.userId = dto.session.id || null;

if (parentLogId) {
const parentLog = await new GetLogUseCase().execute({ params: { logId: parentLogId } });
Expand Down
9 changes: 7 additions & 2 deletions spec/openapi-source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1196,19 +1196,24 @@ components:
additionalProperties: false
User:
allOf:
- $ref: '#/components/schemas/Entity'
- description: Describes an intervention or an event that happened.
type: object
properties:
id:
description: The unique identifier of this entity.
type: integer
format: int64
minimum: 0
externalId:
description: The unique CERN identifier of this user.
type: integer
format: int64
minimum: 1
minimum: 0
name:
type: string
description: Name of the user.
required:
- id
- externalId
- name
additionalProperties: false
Expand Down
17 changes: 6 additions & 11 deletions spec/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated on Sun, 30 Aug 2020 09:11:14 GMT
# Generated on Mon, 14 Sep 2020 22:40:53 GMT

openapi: 3.0.0
info:
Expand Down Expand Up @@ -1342,24 +1342,19 @@ components:
description: Describes an intervention or an event that happened.
type: object
properties:
createdAt:
description: Unix timestamp when this entity was created.
type: integer
format: int64
externalId:
description: The unique CERN identifier of this user.
type: integer
format: int64
minimum: 1
minimum: 0
id:
$ref: '#/components/schemas/EntityId'
description: The unique identifier of this entity.
type: integer
format: int64
minimum: 0
name:
type: string
description: Name of the user.
updatedAt:
description: Unix timestamp when this entity was last updated.
type: integer
format: int64
required:
- externalId
- id
Expand Down