Skip to content

Commit

Permalink
fix(condo): DOMA-9515 fixed send daily statistics task launch (#4909)
Browse files Browse the repository at this point in the history
* fix(condo): DOMA-9515 fixed send daily statistics task launch

* fix(condo): DOMA-9515 fixed send daily statistics task launch

* fix(condo): DOMA-9515 removed unused imports
  • Loading branch information
Alllex202 authored and nomerdvadcatpyat committed Jul 4, 2024
1 parent b88cf13 commit 9d97a67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const LRUCache = require('lru-cache')
const conf = require('@open-condo/config')
const { featureToggleManager } = require('@open-condo/featureflags/featureToggleManager')
const { getLogger } = require('@open-condo/keystone/logging')
const { getSchemaCtx, find, itemsQuery, getByCondition } = require('@open-condo/keystone/schema')
const { find, itemsQuery, getByCondition } = require('@open-condo/keystone/schema')
const { i18n } = require('@open-condo/locales/loader')

const { SEND_DAILY_STATISTICS_TASK } = require('@condo/domains/common/constants/featureflags')
Expand Down Expand Up @@ -38,7 +38,6 @@ class UserDailyStatistics {
#statistics = null
/** @type {string|null} */
#userId = null
#context = null
#taskId = null

/**
Expand All @@ -52,8 +51,6 @@ class UserDailyStatistics {
this.#userId = userId
this.#currentDate = currentDate || dayjs().toISOString()

const { keystone: context } = getSchemaCtx('User')
this.#context = context
this.#taskId = taskId
}

Expand Down Expand Up @@ -99,7 +96,7 @@ class UserDailyStatistics {
data: { organizationId, userId: this.#userId, currentDate: this.#currentDate },
}

const isFeatureEnabled = await featureToggleManager.isFeatureEnabled(this.#context, SEND_DAILY_STATISTICS_TASK, { organization: organizationId })
const isFeatureEnabled = await featureToggleManager.isFeatureEnabled(null, SEND_DAILY_STATISTICS_TASK, { organization: organizationId })
if (!isFeatureEnabled) {
logger.info({
...loggerInfo,
Expand Down
4 changes: 2 additions & 2 deletions apps/condo/domains/analytics/tasks/sendDailyStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ const sendDailyStatistics = async () => {

try {
logger.info({ msg: 'Start sendDailyStatistics', taskId, data: { currentDate } })
const { keystone: context } = getSchemaCtx('User')

const isFeatureEnabled = await featureToggleManager.isFeatureEnabled(context, RETENTION_LOOPS_ENABLED)
const isFeatureEnabled = await featureToggleManager.isFeatureEnabled(null, RETENTION_LOOPS_ENABLED)
if (!isFeatureEnabled) {
logger.info({ msg: 'sendDailyStatistics is disabled', taskId, data: { currentDate } })
return 'disabled'
}

const { keystone: context } = getSchemaCtx('User')
await loadListByChunks({
context,
list: UserAdmin,
Expand Down

0 comments on commit 9d97a67

Please sign in to comment.