feat: update file output paths and add feedback tracking to service schema

- Modified file output paths in LiveKitRoomService to utilize the BUCKET_NAME environment variable for dynamic S3 storage.
- Introduced a new `feedbacked` field in ServiceSchema to track whether a user has provided feedback for a service, enhancing user interaction capabilities.
- Cleaned up the ServiceFeedback schema by refining the resolve function for better clarity and consistency.
This commit is contained in:
2024-12-05 22:11:40 +07:00
parent 1b7329bb44
commit 37b0086b4d
3 changed files with 20 additions and 11 deletions

View File

@@ -48,7 +48,7 @@ export class LiveKitRoomService {
fileOutputs: [ fileOutputs: [
{ {
fileType: EncodedFileType.MP4, fileType: EncodedFileType.MP4,
filepath: `epess/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`, filepath: `${process.env.BUCKET_NAME}/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`,
output: { output: {
case: 's3', case: 's3',
value: { value: {
@@ -93,7 +93,7 @@ export class LiveKitRoomService {
region: process.env.MINIO_REGION, region: process.env.MINIO_REGION,
}, },
}, },
filepath: `epess/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`, filepath: `${process.env.BUCKET_NAME}/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`,
}, },
], ],
}), }),

View File

@@ -115,6 +115,21 @@ export class ServiceSchema extends PothosSchema {
managedService: t.relation('managedService', { managedService: t.relation('managedService', {
description: 'The managed service for the service.', description: 'The managed service for the service.',
}), }),
feedbacked: t.boolean({
description: 'Whether the user has already provided feedback for the service.',
nullable: true,
resolve: async (service, _args, ctx) => {
if (ctx.isSubscription) return null
if (!ctx.http.me) return false
const serviceFeedbacks = await this.prisma.serviceFeedback.findMany({
where: {
serviceId: service.id,
userId: ctx.http.me.id,
},
})
return serviceFeedbacks.length > 0
},
}),
}), }),
}) })
} }

View File

@@ -1,10 +1,5 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
Pothos,
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
@@ -63,9 +58,8 @@ export class ServiceFeedbackSchema extends PothosSchema {
serviceFeedbacks: t.prismaField({ serviceFeedbacks: t.prismaField({
type: [this.serviceFeedback()], type: [this.serviceFeedback()],
args: this.builder.generator.findManyArgs('ServiceFeedback'), args: this.builder.generator.findManyArgs('ServiceFeedback'),
description: description: 'Retrieve a list of service feedbacks with optional filtering, ordering, and pagination.',
'Retrieve a list of service feedbacks with optional filtering, ordering, and pagination.', resolve: async (query, _root, args, _ctx, _info) => {
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.serviceFeedback.findMany({ return await this.prisma.serviceFeedback.findMany({
...query, ...query,
skip: args.skip ?? undefined, skip: args.skip ?? undefined,