diff --git a/src/activities/services/activity-routes.service.ts b/src/activities/services/activity-routes.service.ts index 707cdf9..3e158d4 100644 --- a/src/activities/services/activity-routes.service.ts +++ b/src/activities/services/activity-routes.service.ts @@ -646,7 +646,7 @@ export class ActivityRoutesService { if (!currentUser) { // Allow showing only public ascents to guests builder.andWhere('ar."publish" IN (:...publish)', { - publish: ['log', 'public'], + publish: ['public'], }); // Allow showing only published routes (no drafts or in_reviews) @@ -657,7 +657,7 @@ export class ActivityRoutesService { '(ar.user_id = :userId OR ar."publish" IN (:...publish))', { userId: currentUser.id, - publish: ['log', 'public'], + publish: ['public'], }, ); // TODO: should also allow showing club ascents diff --git a/src/crags/crags.module.ts b/src/crags/crags.module.ts index 1bcb273..10b6783 100644 --- a/src/crags/crags.module.ts +++ b/src/crags/crags.module.ts @@ -71,6 +71,10 @@ import { RouteEvent } from './entities/route-event.entity'; import { Parking } from './entities/parking.entity'; import { ParkingsService } from './services/parkings.service'; import { AreaLoader } from './loaders/area.loader'; +import { ActivityRoutesService } from '../activities/services/activity-routes.service'; +import { ActivitiesModule } from '../activities/activities.module'; +import { ClubMember } from '../users/entities/club-member.entity'; +import { Club } from '../users/entities/club.entity'; @Module({ imports: [ @@ -98,7 +102,10 @@ import { AreaLoader } from './loaders/area.loader'; IceFallProperty, StarRatingVote, Parking, + Club, + ClubMember, ]), + forwardRef(() => ActivitiesModule), forwardRef(() => AuditModule), BullModule.registerQueue({ name: 'summary', @@ -148,6 +155,7 @@ import { AreaLoader } from './loaders/area.loader'; CragLoader, RouteLoader, ParkingsService, + ActivityRoutesService, ], controllers: [UploadController], exports: [ diff --git a/src/crags/resolvers/routes.resolver.ts b/src/crags/resolvers/routes.resolver.ts index 1785f06..09e953a 100644 --- a/src/crags/resolvers/routes.resolver.ts +++ b/src/crags/resolvers/routes.resolver.ts @@ -49,6 +49,9 @@ import { LatestDifficultyVotesInput } from '../dtos/latest-difficulty-votes.inpu import { PaginatedDifficultyVotes } from '../utils/paginated-difficulty-votes'; import { MoveRouteToSectorInput } from '../dtos/move-route-to-sector.input'; import { SectorsService } from '../services/sectors.service'; +import { PaginatedActivityRoutes } from '../../activities/utils/paginated-activity-routes.class'; +import { ActivityRoutesService } from '../../activities/services/activity-routes.service'; +import { FindActivityRoutesInput } from '../../activities/dtos/find-activity-routes.input'; @Resolver(() => Route) @UseInterceptors(DataLoaderInterceptor) @@ -59,12 +62,15 @@ export class RoutesResolver { private difficultyVotesService: DifficultyVotesService, private entityPropertiesService: EntityPropertiesService, private notificationService: NotificationService, + private activityRoutesService: ActivityRoutesService, ) {} /* QUERIES */ @Query(() => Route) @UseFilters(NotFoundFilter) + @AllowAny() + @UseGuards(UserAuthGuard) async route(@Args('id') id: string): Promise { return this.routesService.findOneById(id); } @@ -286,4 +292,17 @@ export class RoutesResolver { ): Promise { return loader.load(route.routeTypeId); } + + @ResolveField('activityRoutes', () => PaginatedActivityRoutes) + @UseGuards(UserAuthGuard) + async activityRoutes( + @Parent() route: Route, + @Args('input', { nullable: true }) input: FindActivityRoutesInput = {}, + @CurrentUser() currentUser: User, + ): Promise { + return this.activityRoutesService.paginate( + { ...input, routeId: route.id }, + currentUser, + ); + } }