Socket connection now works

- Pairing a new device works

(I did a lot since the last commit)
This commit is contained in:
2021-11-14 01:42:21 +01:00
parent 28e85ea730
commit 19b7c05d75
72 changed files with 5861 additions and 23719 deletions

View File

@@ -5,12 +5,16 @@ import { Beat } from "../models/beat/beat.model.";
import { Phone } from "../models/phone/phone.model";
export async function GetBeatStats(req: LivebeatRequest, res: Response) {
const phones = await Phone.find({ user: req.user?._id });
const phones = await Phone.find({ user: req.user?._id }).exec();
const perPhone: any = {};
let totalBeats = 0;
if (phones[0] == undefined) return;
const phone = phones[0];
for (let i = 0; i < phones.length; i++) {
const beatCount = await Beat.countDocuments({ phone: phones[i] });
const beatCount = await Beat.countDocuments({ [phone.id]: phone.id });
perPhone[phones[i]._id] = {};
perPhone[phones[i]._id] = beatCount;
totalBeats += beatCount;