2024-09-20 01:48:28 +03:30
|
|
|
// index.js
|
|
|
|
const express = require('express');
|
|
|
|
const app = express();
|
2024-09-20 20:30:11 +03:30
|
|
|
require('dotenv').config()
|
2024-09-20 01:48:28 +03:30
|
|
|
const cron = require('node-cron')
|
2024-09-20 21:13:24 +03:30
|
|
|
const ical = require('node-ical');
|
2024-09-20 01:48:28 +03:30
|
|
|
|
|
|
|
|
2024-09-20 21:13:24 +03:30
|
|
|
app.get('/get', async (req, res) => {
|
|
|
|
// console.log('Sending target reports to sales executives');
|
|
|
|
res.send( await cc() );
|
2024-09-20 01:48:28 +03:30
|
|
|
|
2024-09-20 21:13:24 +03:30
|
|
|
});
|
2024-09-20 01:48:28 +03:30
|
|
|
app.listen(3000, () => {
|
|
|
|
console.log('Server is running on port 3000');
|
|
|
|
});
|
|
|
|
|
2024-09-20 21:13:24 +03:30
|
|
|
let cc = async () => {
|
|
|
|
return await ical.async.fromURL('https://calendar.google.com/calendar/ical/8535432843cb4e2c6776816cd5097db0365c4e3d7b1e3562ad3e123594966f49%40group.calendar.google.com/private-b917decbb793a04fccd77d1c371aadab/basic.ics',
|
|
|
|
function(err, data) {
|
|
|
|
console.log('VVVVVVVVVVVVVVV', data);
|
|
|
|
})
|
|
|
|
}
|
2024-09-20 20:30:11 +03:30
|
|
|
|
2024-09-20 21:13:24 +03:30
|
|
|
cron.schedule('* * * * *', async () => {
|
|
|
|
await cc()
|
2024-09-20 01:48:28 +03:30
|
|
|
fetchCalendar()
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* calendars
|
|
|
|
* - from
|
|
|
|
* - to
|
|
|
|
* - fetch
|
|
|
|
* - last_fetch
|
|
|
|
*/
|
|
|
|
|
|
|
|
const fetchCalendar = () => {
|
|
|
|
console.log('fetchCalendar');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* upsert records
|
|
|
|
* soft delete
|
|
|
|
* analyze calendar
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
const analyzeCalendar = () => {
|
|
|
|
/**
|
|
|
|
* tag
|
|
|
|
* start
|
|
|
|
* end
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|