completely ditch this bundles intermediate data type
This commit is contained in:
1 parent
6d18a86697
commit
28759f9e70
4 files changed
+16
-72
No files matched your search
+8
-4
@@ -216,7 +216,10 @@ export default function createPg(log: Log, prisma: PrismaClient) {
|
||||
});
|
||||
}
|
||||
|
||||
async function bundleCandidates(): Promise<Listing[][]> {
|
||||
async function interestingListings() {
|
||||
// this basically just needs to return the listingIds to generate offers
|
||||
// but for ease of abstraction we get the listings themselves
|
||||
// grouped by seller
|
||||
const candidates = await prisma.$queryRaw`
|
||||
select
|
||||
seller, count(distinct("wantId")), array_agg(id) as listings
|
||||
@@ -244,7 +247,7 @@ export default function createPg(log: Log, prisma: PrismaClient) {
|
||||
})));
|
||||
}
|
||||
|
||||
async function offersCreate(offers: Offer[]) {
|
||||
async function offersUpdate(offers: Offer[]) {
|
||||
return await prisma.$transaction(
|
||||
offers.map(offer => prisma.offer.upsert({
|
||||
where: {
|
||||
@@ -263,6 +266,7 @@ export default function createPg(log: Log, prisma: PrismaClient) {
|
||||
});
|
||||
}
|
||||
|
||||
// effectively all offers
|
||||
async function offersAdmin() {
|
||||
return prisma.offer.findMany({
|
||||
include: {
|
||||
@@ -291,9 +295,9 @@ export default function createPg(log: Log, prisma: PrismaClient) {
|
||||
listingRmUnlisted,
|
||||
listingByIds,
|
||||
|
||||
bundleCandidates,
|
||||
interestingListings,
|
||||
|
||||
offersCreate,
|
||||
offersUpdate,
|
||||
offerStatusSet,
|
||||
offersAdmin,
|
||||
offerFindId,
|
||||
|
||||
Reference in new issue
Block a user