Skip to content

Commit

Permalink
Fix cron jobs issue and update Footer info
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Graule committed Aug 12, 2024
1 parent 37456ad commit 5dfb7e5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
27 changes: 18 additions & 9 deletions backend/config/functions/cronTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,30 @@ module.exports = {
catalogNumberNORAD: { $ne: null },
}
});
await Promise.all(satellites.map(async satellite => {
const historicalOrbitalData = await fetchOrbitalData(strapi, satellite.catalogNumberNORAD);
await strapi.entityService.update('api::satellite.satellite', satellite.id, {
data: {
historicalOrbitalData: historicalOrbitalData,
}
})
}));
await Promise.all(
satellites.map(async (satellite) => {
const fetchedData = await fetchOrbitalData(satellite.catalogNumberNORAD);
return { id: satellite.id, historicalOrbitalData: fetchedData };
})).then(async (historicalOrbitalData) => {
await strapi.db.transaction(async (trx) => {
// Fetch data for each satellite
historicalOrbitalData.map(async (satellite) => {
// Update the database with the new data
const updatedSat = await strapi.entityService.update('api::satellite.satellite', satellite.id, {
data: {
historicalOrbitalData: satellite.historicalOrbitalData,
},
}, { trx });
})
});
})
} catch (error) {
console.error(error);
return;
}
},
options: {
rule: "0 0 0 8 * *", // Every month on the 3rd at midnight
rule: "0 0 0 3 * *", // Every month on the 3rd at midnight
},
},
};
2 changes: 1 addition & 1 deletion backend/config/functions/satelliteUtils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// backend/utils/satelliteUtils.js
const axios = require('axios');

async function fetchOrbitalData(strapi, noradId) {
async function fetchOrbitalData(noradId) {
try {
// Authentication to Space-Track
const authResponse = await axios.post('https://www.space-track.org/ajaxauth/login', {
Expand Down
14 changes: 4 additions & 10 deletions frontend/src/components/layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,22 @@ export default function Footer() {
<div className="flex flex-col gap-2 text-center">
<div className="flex flex-wrap justify-center gap-x-4">
<a
href="https://www.x.com/NTNU"
className="hover:underline"
>
Twitter
</a>
<a
href="https://www.facebook.com/ntnu.no"
href="https://www.facebook.com/NTNUSmallSat"
className="hover:underline"
>
Facebook
</a>
<a
href="https://www.instagram.com/ntnu"
href="https://www.instagram.com/ntnusmallsat/"
className="hover:underline"
>
Instagram
</a>
<a
href="https://www.youtube.com/user/ntnuinfo"
href="https://www.linkedin.com/company/20559539/"
className="hover:underline"
>
Youtube
LinkedIn
</a>
</div>
<div className="flex flex-row justify-center">
Expand Down

0 comments on commit 5dfb7e5

Please sign in to comment.