mass refactor

This commit is contained in:
2025-09-18 08:31:14 +09:00
parent 856bf3ca2a
commit bdd7d0424f
58 changed files with 3009 additions and 291 deletions

View File

@@ -139,7 +139,10 @@ export class CallbackHandlers {
// Просмотр анкет и свайпы
else if (data === 'start_browsing') {
await this.handleStartBrowsing(chatId, telegramId);
await this.handleStartBrowsing(chatId, telegramId, false);
} else if (data === 'start_browsing_first') {
// Показываем всех пользователей для нового пользователя
await this.handleStartBrowsing(chatId, telegramId, true);
} else if (data === 'vip_search') {
await this.handleVipSearch(chatId, telegramId);
} else if (data.startsWith('search_by_goal_')) {
@@ -330,7 +333,7 @@ export class CallbackHandlers {
}
// Начать просмотр анкет
async handleStartBrowsing(chatId: number, telegramId: string): Promise<void> {
async handleStartBrowsing(chatId: number, telegramId: string, isNewUser: boolean = false): Promise<void> {
const profile = await this.profileService.getProfileByTelegramId(telegramId);
if (!profile) {
@@ -338,7 +341,7 @@ export class CallbackHandlers {
return;
}
await this.showNextCandidate(chatId, telegramId);
await this.showNextCandidate(chatId, telegramId, isNewUser);
}
// Следующий кандидат
@@ -891,8 +894,8 @@ export class CallbackHandlers {
}
}
async showNextCandidate(chatId: number, telegramId: string): Promise<void> {
const candidate = await this.matchingService.getNextCandidate(telegramId);
async showNextCandidate(chatId: number, telegramId: string, isNewUser: boolean = false): Promise<void> {
const candidate = await this.matchingService.getNextCandidate(telegramId, isNewUser);
if (!candidate) {
const keyboard: InlineKeyboardMarkup = {
@@ -1370,12 +1373,28 @@ export class CallbackHandlers {
return;
}
const lifestyle = profile.lifestyle || {};
lifestyle[type as keyof typeof lifestyle] = value as any;
// Обновляем отдельные колонки напрямую, а не через объект lifestyle
const updates: any = {};
switch (type) {
case 'smoking':
updates.smoking = value;
break;
case 'drinking':
updates.drinking = value;
break;
case 'kids':
// Для поля has_kids, которое имеет тип boolean, преобразуем строковые значения
if (value === 'have') {
updates.has_kids = true;
} else {
// Для 'want', 'dont_want', 'unsure' ставим false
updates.has_kids = false;
}
break;
}
await this.profileService.updateProfile(profile.userId, {
lifestyle: lifestyle
});
await this.profileService.updateProfile(profile.userId, updates);
const typeTexts: { [key: string]: string } = {
'smoking': 'курение',