Skip to content

Commit eaae4ff

Browse files
committed
Merge branch 'master-Demo' into HomeTraining-Demo
2 parents 344dce9 + 6b27d12 commit eaae4ff

File tree

140 files changed

+161982
-1743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+161982
-1743
lines changed

โ€Ž.gitignoreโ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
main-HomeTraining/wallpad/exercise/exercise_app/.eslintcache
3+
main-HomeTraining/wallpad/exercise/exercise_app/.eslintcache
4+
main-HomeTraining/wallpad/exercise/exercise_app/src/views/First.css

โ€ŽEC2/car_expire/.gitignoreโ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.env

EC2/express_server/car_expire/car_expire.js renamed to EC2/car_expire/car_expire.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// const schedule = require('node-schedule');
22

3+
const KR_TIME_DIFF = 9 * 60 * 60 * 1000;
4+
35
function carSchema(mongoose, collection) {
46
carModel = mongoose.Schema({
57
category: { type: String, require: true },
@@ -21,12 +23,14 @@ function showCarData(Car) {
2123
console.log(cars);
2224
for (let car of cars) {
2325
if (
24-
Date.now() >=
26+
Date.now() + KR_TIME_DIFF >
2527
Date.parse(car.expireAt.split("T")[0]) + 86400000
2628
) {
2729
console.log(car + " deleted!");
2830
deleteCarData(car, car._id);
2931
}
32+
console.log(Date.now() + KR_TIME_DIFF)
33+
console.log(Date.parse(car.expireAt.split("T")[0]) + 86400000)
3034
}
3135
});
3236
}

โ€ŽEC2/car_expire/main.jsโ€Ž

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const schedule = require("node-schedule");
2+
const mongoose = require("mongoose");
3+
require("dotenv").config();
4+
5+
const MongoURI = process.env.MongoURI;
6+
7+
// DB setting
8+
mongoose.connect(MongoURI);
9+
var db = mongoose.connection;
10+
db.once("open", function () {
11+
console.log("DB connected");
12+
});
13+
db.on("error", function (err) {
14+
console.log("DB ERROR : ", err);
15+
});
16+
17+
var car = require("./car_expire");
18+
var CAR = car.carSchema(mongoose, "cars");
19+
20+
schedule.scheduleJob("1 * * * * *", function () {
21+
// console.log(new Date() + ' scheduler running!');
22+
console.log("---------------------------------------");
23+
24+
car.showCarData(CAR);
25+
});

0 commit comments

Comments
ย (0)