use global context

This commit is contained in:
2026-06-04 16:58:01 +03:30
parent 70711de81c
commit 0d619f313d
17 changed files with 46 additions and 10 deletions
@@ -1,5 +1,6 @@
import { Injectable, Logger } from '@nestjs/common';
import { Cron } from '@nestjs/schedule';
import { CreateRequestContext } from '@mikro-orm/core';
import { EntityManager } from '@mikro-orm/postgresql';
import { Restaurant } from '../entities/restaurant.entity';
@@ -14,6 +15,7 @@ export class RestaurantCrone {
name: 'deactivateExpiredSubscriptions',
timeZone: 'UTC',
})
@CreateRequestContext()
async handleCron() {
try {
this.logger.debug('Starting daily subscription expiration check');
@@ -139,10 +139,8 @@ export class RestaurantsService {
}
async findOneBySubscriptionId(subscriptionId: string): Promise<Restaurant> {
console.log('subscriptionId', subscriptionId)
const restaurant = await this.restRepository.findOne({ subscriptionId });
console.log('restaurant', restaurant)
if (!restaurant) {
const restaurant = await this.restRepository.findOne({ subscriptionId });
if (!restaurant) {
throw new NotFoundException(RestMessage.NOT_FOUND);
}
return restaurant;