-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #437 from bluewave-labs/develop
Develop
- Loading branch information
Showing
64 changed files
with
1,223 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Describe your changes | ||
|
||
Briefly describe the changes you made and their purpose. | ||
|
||
## Issue number | ||
|
||
Mention the issue number(s) this PR addresses (e.g., #123). | ||
|
||
## Please ensure all items are checked off before requesting a review: | ||
|
||
- [ ] I deployed the code locally. | ||
- [ ] I have performed a self-review of my code. | ||
- [ ] I have included the issue # in the PR. | ||
- [ ] I have labelled the PR correctly. | ||
- [ ] The issue I am working on is assigned to me. | ||
- [ ] I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application). | ||
- [ ] I made sure font sizes, color choices etc are all referenced from the theme. | ||
- [ ] My PR is granular and targeted to one specific feature. | ||
- [ ] I took a screenshot or a video and attached to this PR if there is a UI change. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use strict"; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
/** | ||
* Add altering commands here. | ||
* | ||
* Example: | ||
* await queryInterface.createTable('users', { id: Sequelize.INTEGER }); | ||
*/ | ||
await queryInterface.addIndex("guide_logs", ["showingTime"], { | ||
name: "idx_guide_logs_showingTime", | ||
}); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.removeIndex("guide_logs", ["showingTime"], { | ||
name: "idx_guide_logs_showingTime", | ||
}); | ||
/** | ||
* Add reverting commands here. | ||
* | ||
* Example: | ||
* await queryInterface.dropTable('users'); | ||
*/ | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const statisticsService = require("../service/statistics.service"); | ||
const { internalServerError } = require("../utils/errors.helper"); | ||
|
||
class StatisticsController { | ||
async getStatistics(req, res) { | ||
try { | ||
const userId = req.user.id; | ||
const statistics = await statisticsService.generateStatistics({ | ||
userId: userId.toString(), | ||
}); | ||
res.status(200).json(statistics); | ||
} catch (e) { | ||
console.log(e) | ||
const { statusCode, payload } = internalServerError( | ||
"GET_STATISTICS_ERROR", | ||
e.message | ||
); | ||
res.status(statusCode).json(payload); | ||
} | ||
} | ||
} | ||
|
||
module.exports = new StatisticsController(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,64 @@ | ||
const { GuideType } = require('../utils/guidelog.helper'); | ||
const { GuideType } = require("../utils/guidelog.helper"); | ||
|
||
module.exports = (sequelize, DataTypes) => { | ||
const GuideLog = sequelize.define('GuideLog', { | ||
guideType: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
validate: { | ||
isIn: { | ||
args: [ | ||
Object.values(GuideType), | ||
], | ||
msg: 'guideType must be a valid value.', | ||
}, | ||
}, | ||
const GuideLog = sequelize.define( | ||
"GuideLog", | ||
{ | ||
guideType: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
validate: { | ||
isIn: { | ||
args: [Object.values(GuideType)], | ||
msg: "guideType must be a valid value.", | ||
}, | ||
}, | ||
guideId: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
}, | ||
guideId: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
}, | ||
userId: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
showingTime: { | ||
type: DataTypes.DATE, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
completed: { | ||
type: DataTypes.BOOLEAN, | ||
defaultValue: false, | ||
}, | ||
}, | ||
{ | ||
timestamps: false, | ||
tableName: "guide_logs", | ||
indexes: [ | ||
{ | ||
name: "idx_guide_logs_userId", | ||
fields: ["userId"], | ||
}, | ||
userId: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
{ | ||
name: "idx_guide_logs_guideId", | ||
fields: ["guideId"], | ||
}, | ||
showingTime: { | ||
type: DataTypes.DATE, | ||
defaultValue: DataTypes.NOW, | ||
{ | ||
name: "idx_guide_logs_guideType", | ||
fields: ["guideType"], | ||
}, | ||
completed: { | ||
type: DataTypes.BOOLEAN, | ||
defaultValue: false, | ||
{ | ||
name: "idx_guide_logs_userId_guideId_guideType", | ||
fields: ["userId", "guideId", "guideType"], | ||
unique: false, | ||
}, | ||
}, { | ||
timestamps: false, | ||
tableName: 'guide_logs', | ||
indexes: [ | ||
{ | ||
name: 'idx_guide_logs_userId', | ||
fields: ['userId'], | ||
}, | ||
{ | ||
name: 'idx_guide_logs_guideId', | ||
fields: ['guideId'], | ||
}, | ||
{ | ||
name: 'idx_guide_logs_guideType', | ||
fields: ['guideType'], | ||
}, | ||
{ | ||
name: 'idx_guide_logs_userId_guideId_guideType', | ||
fields: ['userId', 'guideId', 'guideType'], | ||
unique: false, | ||
}, | ||
], | ||
}); | ||
{ | ||
name: "idx_guide_logs_showingTime", | ||
fields: ["showingTime"], | ||
}, | ||
], | ||
} | ||
); | ||
|
||
return GuideLog; | ||
return GuideLog; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const express = require("express"); | ||
const statisticsController = require("../controllers/statistics.controller"); | ||
const authenticateJWT = require("../middleware/auth.middleware"); | ||
|
||
const router = express.Router(); | ||
router.use(authenticateJWT) | ||
router.get("/", statisticsController.getStatistics); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.