add user profile, profile vibe and trip vibe and social signal
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { Prisma } from "@/app/generated/prisma/client";
|
||||
import type { Vibe } from "@/app/generated/prisma/enums";
|
||||
|
||||
export interface PeopleFilters {
|
||||
city?: string;
|
||||
interest?: string;
|
||||
vibe?: Vibe;
|
||||
}
|
||||
|
||||
export const userRepo = {
|
||||
async findByEmail(email: string) {
|
||||
@@ -42,6 +49,7 @@ export const userRepo = {
|
||||
city: true,
|
||||
interests: true,
|
||||
instagram: true,
|
||||
vibe: true,
|
||||
},
|
||||
},
|
||||
organizerVerification: { select: { status: true } },
|
||||
@@ -49,6 +57,56 @@ export const userRepo = {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Discovery /people: ambil user yang punya profil sosial terisi (minimal salah
|
||||
* satu dari bio/city/interests/vibe). Filter optional by city/interest/vibe.
|
||||
* Tidak ekspos email/KYC.
|
||||
*/
|
||||
async findPeople(filters?: PeopleFilters, limit = 60) {
|
||||
const profileWhere: Prisma.UserProfileWhereInput = {
|
||||
OR: [
|
||||
{ bio: { not: null } },
|
||||
{ city: { not: null } },
|
||||
{ vibe: { not: null } },
|
||||
{ interests: { isEmpty: false } },
|
||||
],
|
||||
};
|
||||
|
||||
if (filters?.city) {
|
||||
profileWhere.city = {
|
||||
contains: filters.city,
|
||||
mode: "insensitive",
|
||||
};
|
||||
}
|
||||
if (filters?.interest) {
|
||||
profileWhere.interests = { has: filters.interest.toLowerCase() };
|
||||
}
|
||||
if (filters?.vibe) {
|
||||
profileWhere.vibe = filters.vibe;
|
||||
}
|
||||
|
||||
return prisma.user.findMany({
|
||||
where: { profile: { is: profileWhere } },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
image: true,
|
||||
createdAt: true,
|
||||
profile: {
|
||||
select: {
|
||||
bio: true,
|
||||
city: true,
|
||||
interests: true,
|
||||
vibe: true,
|
||||
},
|
||||
},
|
||||
organizerVerification: { select: { status: true } },
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: limit,
|
||||
});
|
||||
},
|
||||
|
||||
async create(data: Prisma.UserCreateInput) {
|
||||
return prisma.user.create({ data });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user