Skip to content

Commit 4fe8d51

Browse files
added automatic deletion of old mocks
1 parent 65243d6 commit 4fe8d51

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Cleanup Old Mocks # Name of the workflow (you'll see this in GitHub Actions tab)
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Trigger workflow automatically every day at 00:00 UTC
6+
workflow_dispatch: # Allow manual trigger from GitHub UI
7+
8+
jobs:
9+
cleanup: # Define a job named "cleanup"
10+
runs-on: ubuntu-latest # Use GitHub's Ubuntu virtual machine
11+
12+
steps: # Define the steps inside this job
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
# Pulls your repository code into the Ubuntu VM
16+
# Needed so the runner has access to cleanup.js
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: 18
22+
# Installs Node.js v18 on the VM so we can run JavaScript
23+
24+
- name: Install mongoose
25+
run: npm install mongoose
26+
# Instead of `npm install`, we only install mongoose
27+
# because cleanup.js only depends on mongoose
28+
29+
- name: Run cleanup script
30+
env:
31+
MONGO_URI: ${{ secrets.MONGO_URI }}
32+
# Inject MongoDB connection string securely from GitHub Secrets
33+
run: node cleanup.js
34+
# Runs the cleanup.js script to delete old mocks

BackEnd/cleanUp.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,9 @@ async function cleanUp(){
77
await mongoose.connect("mongodb+srv://WHQMCNBYGhTTwIHN:ankitchauhan21500@cluster0.2ipp9om.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0");
88

99
const today = new Date();
10-
today.setHours(0, 0, 0, 0);
1110
console.log(today);
1211
const result = await mockModel.deleteMany({schedule : {$lt : today}});
1312
console.log(result);
1413
// await find
1514
}
16-
17-
let temp = new Date();
18-
if(temp < new Date("Wed Aug 20 2025 9:30 AM")){
19-
console.log("ok");
20-
}
21-
else{
22-
console.log("tattii");
23-
}
24-
cleanUp();
15+
cleanUp();

frontEnd/src/Components/Home/Home.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function Home() {
1717
}
1818

1919
return (
20-
<div className="p-12 pt-0 pb-0 bg-gradient-to-br from-indigo-50 to-purple-50">
20+
<div className="p-4 pt-0 pb-0 bg-gradient-to-br from-indigo-50 to-purple-50">
2121
<div className="container mx-auto px-4 py-12">
2222
<main className="flex flex-col md:flex-row items-center justify-between gap-12">
2323
<div className="max-w-xl">

frontEnd/src/Components/Schedule/Schedule.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function Schedule() {
6060
function getNextFourDays() {
6161
const dates = [];
6262
const today = new Date();
63-
for (let i = 0; i < 4; i++) {
63+
for (let i = -2; i < 4; i++) {
6464
const nextDate = new Date(today);
6565
nextDate.setDate(today.getDate() + i + 1);
6666
dates.push(nextDate.toDateString());

0 commit comments

Comments
 (0)