updates to teamsnapCallback

This commit is contained in:
2024-03-10 14:01:09 -05:00
parent 7efb083e1d
commit a9fa89107e
9 changed files with 77 additions and 63 deletions

View File

@@ -1,6 +1,7 @@
tsUtils = require("../lib/utils");
const path = require('path');
const { teamsnapFailure, tsPromise } = require("../lib/utils");
const { teamsnapFailure, tsPromise, teamsnapCallback } = require("../lib/utils");
const {promisify} = require('util')
exports.helpers = {
@@ -23,8 +24,12 @@ exports.partials = path.join(__dirname, "../views/event/partials")
exports.getEvents = async (req, res, next) => {
const {user, team, layout} = req
const bulkLoadTypes = ["event", "availabilitySummary"]
req.promises.push(
tsPromise('bulkLoad', {teamId: team.id, types: bulkLoadTypes})
// const tsPromiseBulkload = promisify(teamsnap.bulkLoad)
const promise = teamsnap.bulkLoad(
{teamId: team.id, types: bulkLoadTypes},
undefined,
(err,items) => {teamsnapCallback(err, items, {req, source: 'getEvents', method: 'bulkLoad'})}
)
.then(items=>tsUtils.groupTeamsnapItems(items))
.then(items=>{
items.events.forEach((event) => {
@@ -34,13 +39,10 @@ exports.getEvents = async (req, res, next) => {
req.events = items.events;
}
)
.then(tsUtils.teamsnapLog('bulkLoad', types=bulkLoadTypes, team.id, req))
.catch((err) => {
teamsnapFailure(err,next)
})
)
await Promise.all(req.promises)
req.promises.push(promise)
all = await Promise.all(req.promises)
try {
const context = {
title: "Events",