-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script/route for automating slot data creation for 3 days
- Loading branch information
Showing
8 changed files
with
146 additions
and
111 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,18 @@ | ||
#!/bin/bash | ||
|
||
docker build -t lasertag-backend . | ||
# Start your containers with docker-compose | ||
docker-compose up -d | ||
|
||
# Wait for all containers to be healthy (customize as needed) | ||
docker-compose ps | grep ' Up ' | wc -l | while read -r count; do | ||
if [ "$count" -lt $(docker-compose ps | grep ' Up ' | wc -l) ]; then | ||
sleep 1 | ||
else | ||
break | ||
fi | ||
done | ||
|
||
# Run your post-startup commands here | ||
echo "All containers are up and running. Running post-startup commands..." | ||
|
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
import Slot from "../models/slotModel.js"; | ||
import catchAsync from "../helpers/catchAsync.js"; | ||
import moment from "moment-timezone"; | ||
|
||
const year = 2023; | ||
const month = 9; | ||
const monthDays = [22, 23, 24]; | ||
const hours = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]; | ||
const mins = [0, 10, 15, 25, 30, 40, 45, 55]; | ||
const curTimezone = 'Asia/Kolkata'; | ||
const targetTimezone = 'UTC'; | ||
|
||
const CreateSlotDataController = catchAsync( | ||
async () => { | ||
for (let dy of monthDays) { | ||
let carrySlotTime = new moment.tz([year, month, dy, 8, 30, 0], curTimezone).tz(targetTimezone).toDate(); | ||
for (let hr of hours) { | ||
for (let mn = 0; mn < mins.length; mn += 2) { | ||
let startTime = new moment.tz([year, month, dy, hr, mins[mn], 0], curTimezone).tz(targetTimezone).toDate(); | ||
let endTime = new moment.tz([year, month, dy, hr, mins[mn + 1], 0], curTimezone).tz(targetTimezone).toDate(); | ||
let day = 1; | ||
let isCarry = false; | ||
if (dy == 22) { | ||
day = 1; | ||
} | ||
else if (dy == 23) { | ||
day = 2; | ||
} | ||
else { | ||
day = 3; | ||
} | ||
if (hr == 8) { | ||
if (startTime.getTime() <= carrySlotTime.getTime()) { | ||
isCarry = true; | ||
} | ||
} | ||
|
||
let newSlot = { | ||
startTime: startTime, | ||
endTime: endTime, | ||
day: day, | ||
isCarry: isCarry | ||
}; | ||
|
||
Slot.create([newSlot]) | ||
.catch((err) => { | ||
console.log(`Slot unable to be created: ${err}`); | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
export default CreateSlotDataController; |
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,54 @@ | ||
import Slot from "../models/slotModel.js"; | ||
import User from "../models/userModel.js"; | ||
import catchAsync from "../helpers/catchAsync.js"; | ||
import Logger from "../initializers/logger.js"; | ||
import moment from "moment-timezone"; | ||
|
||
const CreateUserDataController = catchAsync( | ||
async (req, res) => { | ||
User.deleteMany({}); | ||
Slot.deleteMany({}); | ||
User.create([ | ||
{ | ||
regno: "22BCE2700", | ||
phoneno: "7483555328", | ||
email: "[email protected]", | ||
scope: "ADMIN" | ||
}, | ||
{ | ||
regno: "22BKT0060", | ||
email: "[email protected]", | ||
scope: "ADMIN" | ||
}, | ||
{ | ||
email: "[email protected]" | ||
}, | ||
{ | ||
email: "[email protected]" | ||
}, | ||
{ | ||
email: "[email protected]" | ||
}, | ||
{ | ||
email: "[email protected]" | ||
}, | ||
{ | ||
email: "[email protected]" | ||
}, | ||
{ | ||
email: "[email protected]" | ||
} | ||
]) | ||
.then((createdUser) => { | ||
console.log("User Created: " + createdUser); | ||
}) | ||
.catch((err) => { | ||
console.log("Unable to create User: " + err); | ||
}); | ||
|
||
Logger.info("Dummy data created."); | ||
return res.status(200).json({message: "Dummy data succesfully created."}); | ||
} | ||
); | ||
|
||
export default CreateUserDataController; |
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 was deleted.
Oops, something went wrong.
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,8 @@ | ||
import express from "express"; | ||
import CreateSlotDataController from "../controllers/slotdata.js"; | ||
|
||
const createslotdata = express.Router(); | ||
|
||
createslotdata.post("/", CreateSlotDataController); | ||
|
||
export default createslotdata; |
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,8 @@ | ||
import express from "express"; | ||
import CreateUserDataController from "../controllers/createuserdatacontroller.js"; | ||
|
||
const createuserdata = express.Router(); | ||
|
||
createuserdata.post("/", CreateUserDataController); | ||
|
||
export default createuserdata; |