Enhance MyTischtennisUrlController with ratings update and improve apiLogService truncation limits
Added functionality in MyTischtennisUrlController to update (Q)TTR ratings for clubs based on user authentication. Enhanced error handling for ratings updates to provide clearer feedback. Updated apiLogService to increase truncation limits for request and response bodies, accommodating larger API JSON payloads, ensuring better logging accuracy.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import myTischtennisUrlParserService from '../services/myTischtennisUrlParserService.js';
|
||||
import myTischtennisService from '../services/myTischtennisService.js';
|
||||
import MemberService from '../services/memberService.js';
|
||||
import autoFetchMatchResultsService from '../services/autoFetchMatchResultsService.js';
|
||||
import apiLogService from '../services/apiLogService.js';
|
||||
import ClubTeam from '../models/ClubTeam.js';
|
||||
@@ -383,13 +384,24 @@ class MyTischtennisUrlController {
|
||||
// Don't fail the entire request if table update fails
|
||||
}
|
||||
|
||||
// Additionally update (Q)TTR ratings for the club
|
||||
let ratingsUpdate = null;
|
||||
try {
|
||||
// Use already resolved userId instead of authcode to avoid header dependency
|
||||
const ratingsResult = await MemberService.updateRatingsFromMyTischtennisByUserId(userId, team.clubId);
|
||||
ratingsUpdate = ratingsResult?.response?.message || `Ratings update status: ${ratingsResult?.status}`;
|
||||
} catch (ratingsErr) {
|
||||
ratingsUpdate = 'Ratings update failed: ' + (ratingsErr.message || String(ratingsErr));
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
message: `${result.fetchedCount} Datensätze abgerufen und verarbeitet`,
|
||||
data: {
|
||||
fetchedCount: result.fetchedCount,
|
||||
teamName: team.name,
|
||||
tableUpdate: tableUpdateResult
|
||||
tableUpdate: tableUpdateResult,
|
||||
ratingsUpdate
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user