Skip to content

Commit c961dcb

Browse files
committed
improve sync logging
1 parent f0703c8 commit c961dcb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/sync.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,13 @@ async function syncUsers(fast42Api: Fast42, lastPullDate: Date | undefined): Pro
148148
const campuses = await DatabaseService.getAllCampuses();
149149
let campusIds = campuses.map(c => c.id);
150150
try {
151-
for (const campusId of campusIds) {
151+
const totalCampuses = campusIds.length;
152+
for (let [index, campusId] of campusIds.entries()) {
152153
params['filter[primary_campus_id]'] = campusId.toString();
153154
while (hasMorePages) {
154155
pageIndex++;
155156
params['page[number]'] = pageIndex.toString();
156-
log(2, `Fetching page ${pageIndex} of users for campus ${campusId}...`);
157+
log(2, `Fetching page ${pageIndex} of users for campus ${campusId} (${index + 1}/${totalCampuses})...`);
157158

158159
let usersData;
159160
try {
@@ -203,11 +204,12 @@ async function syncProjectUsers(fast42Api: Fast42, lastPullDate: Date | undefine
203204
const projects = await DatabaseService.getAllProjects();
204205
let projectIds = projects.map(p => p.id);
205206
try {
206-
for (const projectId of projectIds) {
207+
const totalProjects = projectIds.length;
208+
for (let [index, projectId] of projectIds.entries()) {
207209
while (hasMorePages) {
208210
pageIndex++;
209211
params['page[number]'] = pageIndex.toString();
210-
log(2, `Fetching page ${pageIndex} of projectUsers...`);
212+
log(2, `Fetching page ${pageIndex} of projectUsers for project ${projectId} (${index + 1}/${totalProjects})...`);
211213

212214
let projectUsersData;
213215
try {

0 commit comments

Comments
 (0)