updates to teamsnapCallback
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -10,7 +10,6 @@ exports.getTeams = async (req, res, next) => {
|
||||
teamsnapCallback(err,items);
|
||||
req.teams = items;
|
||||
})
|
||||
.then(() => tsUtils.teamsnapLog('loadTeams', types=['teams'], null, req))
|
||||
.fail(
|
||||
next
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user