Skip to content

Commit

Permalink
Close #190 (PR #201)
Browse files Browse the repository at this point in the history
Frequência média de pessoas por mês.
  • Loading branch information
silvioantonio authored Jul 13, 2020
1 parent 7723f8c commit 1a00c02
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/controllers/localizacao.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,15 @@ exports.getFrequenciaMediaVisitantas = async (req, res) => {
try {
const hourArray = await selectFrequenciaMediaVisitantas(client, 'HOUR', lat1, lat2, lng1, lng2);
const dayArray = await selectFrequenciaMediaVisitantas(client, 'DAY', lat1, lat2, lng1, lng2);
const monthArray = await selectFrequenciaMediaVisitantas(client, 'MONTH', lat1, lat2, lng1, lng2);

const hourSet = new Set(hourArray.map(row => row.hour));
const daySet = new Set(dayArray.map(row => row.day));
const monthSet = new Set(monthArray.map(row => row.month));

frequenciaMedia.hora = hourArray.length / hourSet.size;
frequenciaMedia.dia = dayArray.length / daySet.size;
frequenciaMedia.mes = monthArray.length / monthSet.size;

return res.status(200).json(frequenciaMedia);
} catch (error) {
Expand Down

0 comments on commit 1a00c02

Please sign in to comment.