Skip to content

Commit

Permalink
force merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bentran1vn committed Oct 4, 2023
2 parents 56f4306 + b2d2c35 commit 2139db4
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 29 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/master_minion-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js app to Azure Web App - minion-2

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '18.x'

- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: node-app
path: .

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: node-app

- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'minion-2'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_41997CE4E64D4079A3F84DD1E541B1C5 }}
package: .
4 changes: 2 additions & 2 deletions models/ExamRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ const ExamRoom = sequelize.define(tableName, {
},
roomId: {
type: DataTypes.INTEGER,
allowNull: false,
allowNull: true,
references: {
model: Room,
key: 'id'
}
},
lecturerId: {
type: DataTypes.INTEGER,
allowNull: false,
allowNull: true,
references: {
model: Lecturer,
key: 'id'
Expand Down
4 changes: 2 additions & 2 deletions routes/examPhase.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { countCourse } from './course.js'

const router = express.Router()

router.post('/create', async (req, res) => {
router.post('/', async (req, res) => {
const semId = parseInt(req.body.semId);
const eTId = parseInt(req.body.eTId);
const startDay = req.body.startDay;
Expand Down Expand Up @@ -69,7 +69,7 @@ router.put('/', async (req, res) => { // Update ExamPhase
}
})

router.delete('/', async (req, res) => {
router.delete('/', async (req, res) => { // Delete Exam Phase
const id = parseInt(req.body.id)

try {
Expand Down
27 changes: 10 additions & 17 deletions routes/examSlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import fs from 'fs'

const router = express.Router()

router.post('/create', async (req, res) => {
router.post('/', async (req, res) => {
const ePId = parseInt(req.body.ePId);
const timeSlotId = parseInt(req.body.timeSlotId);
const day = req.body.day;
Expand Down Expand Up @@ -106,34 +106,27 @@ router.get('/', async (req, res) => {
let dayCount = 0
let slotCount = 0



for (let i = 0; i < course.length; i++) {
let daySlot = dayList[dayCount]
let slot = slotList[slotCount].id
if (roomSlot > process.env.NUMBER_OF_ROOM_IN_FLOOR * process.env.NUMBER_OF_ROOM_IN_FLOOR){

if (roomSlot > process.env.NUMBER_OF_ROOM_IN_FLOOR * process.env.NUMBER_OF_ROOM_IN_FLOOR) {
roomSlot = 0
slotCount++;
if(slotCount > process.env.NUMBER_OF_SLOT - 1){

if (slotCount > process.env.NUMBER_OF_SLOT - 1) {
slotCount = 0
dayCount++;
}
}


const val = course[i];
let roomCourse = Math.ceil(val.numOfStu / process.env.NUMBER_OF_STUDENT_IN_ROOM)
//fs.appendFileSync("test.txt", roomCourse + "\n");
roomSlot += roomCourse

let examSlot = await ExamSlot.create({
ePId: examPhaseList[key].id,
day: dayList[0],
timeSlotId: slotList[0]
})

if(roomSlot <= process.env.NUMBER_OF_STUDENT_IN_ROOM* process.env.NUMBER_OF_ROOM_IN_FLOOR){
for (let i = 0; i < roomCourse; i++) {
let data = val.id + ".." + daySlot.getDate() + ".." + slot
Expand All @@ -148,9 +141,9 @@ router.get('/', async (req, res) => {
})
i--
}

}

}
res.json('hihi')
})
Expand Down
2 changes: 1 addition & 1 deletion routes/room.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express from 'express'
import { DataResponse, InternalErrResponse, InvalidTypeResponse, MessageResponse, NotFoundResponse } from '../common/reponses.js'
import { requireRole } from '../middlewares/auth.js'
import Rooms from '../models/Room.js'
import Room from '../models/Room.js'


const router = express.Router()
Expand Down
12 changes: 6 additions & 6 deletions routes/timeSlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ router.get('/getAll', async (req, res) => {
//get All timeSlot
try {
const timeSlots = await TimeSlot.findAll();
if(!timeSlots){
if (!timeSlots) {
res.json(NotFoundResponse());
}else{
} else {
res.json(DataResponse(timeSlots));
}
} catch (error) {
console.log(error);
res.json(InternalErrResponse());
}
}
})

router.get('/getMultipleId', async (req,res) => {
router.get('/getMultipleId', async (req, res) => {
//tìm theo id khi người dùng nhập dạng "id" = "1,2,3,4,5,6,7"
const id = req.body.id.split(',');
console.log(id);
try {
const timeSlots = await TimeSlot.findAll({
where: {
id: {
[Op.or] : id
[Op.or]: id
}
}
}
Expand Down Expand Up @@ -127,7 +127,7 @@ router.delete('/deleteAll', async (req, res) => {
})


router.put('/update', async (req, res) => {
router.put('/', async (req, res) => {
//update time slot theo id
const id = parseInt(req.body.id)
const timeSlotData = req.body;
Expand Down
13 changes: 12 additions & 1 deletion routes/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ import { requireRole } from "../middlewares/auth.js";

const router = express.Router()

router.post('/registers', async (req, res) => {
router.get('/', async (req, res) => {
const pageNo = parseInt(req.query.page_no) || 1
const limit = parseInt(req.query.limit) || 20

const users = await User.findAll({
limit: limit,
offset: (pageNo - 1) * limit
})
res.json(DataResponse(users))
})

router.post('/', async (req, res) => {
const userData = req.body
await User.create(
{
Expand Down

0 comments on commit 2139db4

Please sign in to comment.