progress
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
const { RedisClient } = require('../../db/redis/redis');
|
||||
const { request } = require('../request');
|
||||
|
||||
const getHistoricalSessions = async({ callsign, userId, from, to }) => {
|
||||
@ -41,6 +42,58 @@ async function _requestHistoricalRecursive(data, url, options) {
|
||||
}
|
||||
}
|
||||
|
||||
async function getIvaoSessionTracks(idSession) {
|
||||
const url = `https://api.ivao.aero/v2/tracker/sessions/${idSession}/tracks`;
|
||||
const options = {
|
||||
headers: {
|
||||
apiKey: process.env.IVAO_APIKEY,
|
||||
},
|
||||
};
|
||||
const tracks = await request(url, options);
|
||||
return tracks;
|
||||
}
|
||||
async function getIvaoSessionLatestTrack(idSession) {
|
||||
const url = `https://api.ivao.aero/v2/tracker/sessions/${idSession}/tracks/latest`;
|
||||
const options = {
|
||||
headers: {
|
||||
apiKey: process.env.IVAO_APIKEY,
|
||||
},
|
||||
};
|
||||
const tracks = await request(url, options);
|
||||
return tracks;
|
||||
}
|
||||
|
||||
|
||||
async function getIvaoPilotsNow(all = false) {
|
||||
const url = `https://api.ivao.aero/v2/tracker/now/pilots`;
|
||||
const options = {
|
||||
headers: {
|
||||
apiKey: process.env.IVAO_APIKEY,
|
||||
},
|
||||
};
|
||||
const redisUsers = await RedisClient.getPair('users');
|
||||
const pilots = await request(url, options);
|
||||
// console.log('redisUsers :>> ', redisUsers);
|
||||
|
||||
return all ? pilots : pilots.filter(d => d.callsign.startsWith('LTS'));
|
||||
}
|
||||
|
||||
async function getIvaoLatestSessionFlightPlan(sessionId) {
|
||||
const url = `https://api.ivao.aero/v2/tracker/sessions/${sessionId}/flightPlans/latest`;
|
||||
const options = {
|
||||
headers: {
|
||||
apiKey: process.env.IVAO_APIKEY,
|
||||
},
|
||||
};
|
||||
|
||||
const fp = await request(url, options);
|
||||
return fp;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getHistoricalSessions,
|
||||
getIvaoSessionTracks,
|
||||
getIvaoPilotsNow,
|
||||
getIvaoLatestSessionFlightPlan,
|
||||
getIvaoSessionLatestTrack,
|
||||
}
|
Reference in New Issue
Block a user