Skip to content

Commit

Permalink
#13 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafa-guner committed Apr 28, 2024
1 parent 7627e57 commit 4cfa3c7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
6 changes: 3 additions & 3 deletions controllers/PersonnelController.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
where: { id: serviceType.id }
}]
});
console.log(serviceType.id);

const message = await Message.findOne({ where: { service_type_id: serviceType.id } });
if (!message) throw new Error('Message not found for this service type');

Expand All @@ -37,7 +37,7 @@ console.log(serviceType.id);
<p>There is a new task:</p>
<ul>
<li>Room ID: ${room_id}</li>
<li>Service Type: ${serviceTypeModel.title}</li>
<li>Service Type: ${serviceType.title}</li>
<li>Task Token: ${newTask.token}</li>
</ul>
<p>Please click on the following link to claim the task:</p>
Expand All @@ -60,7 +60,7 @@ console.log(serviceType.id);
});

} catch (error) {
console.error('An error occurred:', error);
console.error('An error occurred:', error.message);
return res.status(500).json({
success: false,
message: "Internal server error."
Expand Down
Binary file modified database.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion migrations/20240427212159-create-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
},
personnel_id: {
type: Sequelize.INTEGER,
allowNull: false,
allowNull: true,
references: {
model: 'Personnel',
key: 'id'
Expand Down
2 changes: 1 addition & 1 deletion schemas/associations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const PersonnelServiceType = require('./personnel_service_type');

Personnel.belongsToMany(ServiceType, { through: PersonnelServiceType, foreignKey: 'personnel_id' });
ServiceType.belongsToMany(Personnel, { through: PersonnelServiceType, foreignKey: 'service_type_id' });
// Message.belongsTo(ServiceType, { foreignKey: 'service_type_id' });


(async () => {
await sequelize.sync();
Expand Down
20 changes: 14 additions & 6 deletions schemas/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ const Task = sequelize.define('Tasks', {
},
service_type_id: {
type: DataTypes.INTEGER,
allowNull: false
},
personnel_id: {
type: DataTypes.INTEGER,
allowNull: false
},
allowNull: true,
references: {
model: 'ServiceTypes',
key: 'id'
}
},
personnel_id: {
type: DataTypes.INTEGER,
allowNull: true,
references: {
model: 'Personnel',
key: 'id'
}
},
claimed_at: {
type: DataTypes.DATE,
allowNull: true
Expand Down

0 comments on commit 4cfa3c7

Please sign in to comment.