feat: add VIP search option and profile editing functionality
- Added a new button for '⭐ VIP поиск' in command handlers.
- Implemented profile editing states and methods in message handlers.
- Enhanced profile model to include hobbies, religion, dating goals, and lifestyle preferences.
- Updated profile service to handle new fields and ensure proper database interactions.
- Introduced a VIP function in matching service to find candidates based on dating goals.
This commit is contained in:
@@ -381,4 +381,34 @@ export class MatchingService {
|
||||
// Используем ProfileService для правильного маппинга данных
|
||||
return this.profileService.mapEntityToProfile(candidateData);
|
||||
}
|
||||
|
||||
// VIP функция: поиск кандидатов по цели знакомства
|
||||
async getCandidatesWithGoal(userProfile: Profile, targetGoal: string): Promise<Profile[]> {
|
||||
const swipedUsersResult = await query(`
|
||||
SELECT swiped_id
|
||||
FROM swipes
|
||||
WHERE swiper_id = $1
|
||||
`, [userProfile.userId]);
|
||||
|
||||
const swipedUserIds = swipedUsersResult.rows.map((row: any) => row.swiped_id);
|
||||
swipedUserIds.push(userProfile.userId); // Исключаем себя
|
||||
|
||||
let candidateQuery = `
|
||||
SELECT DISTINCT p.*, u.telegram_id, u.username, u.first_name, u.last_name
|
||||
FROM profiles p
|
||||
JOIN users u ON p.user_id = u.id
|
||||
WHERE p.is_visible = true
|
||||
AND p.is_active = true
|
||||
AND p.gender = $1
|
||||
AND p.dating_goal = $2
|
||||
AND p.user_id NOT IN (${swipedUserIds.map((_: any, i: number) => `$${i + 3}`).join(', ')})
|
||||
ORDER BY p.created_at DESC
|
||||
LIMIT 50
|
||||
`;
|
||||
|
||||
const params = [userProfile.interestedIn, targetGoal, ...swipedUserIds];
|
||||
const result = await query(candidateQuery, params);
|
||||
|
||||
return result.rows.map((row: any) => this.profileService.mapEntityToProfile(row));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user