Support for rating system (#10124)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-10-24 10:10:01 +07:00
committed by GitHub
parent 768ff39ab1
commit ffd8d90378
137 changed files with 5005 additions and 712 deletions
+43 -17
View File
@@ -562,23 +562,23 @@ services:
- QUEUE_CONFIG=${QUEUE_CONFIG}
- QUEUE_REGION=cockroach
restart: unless-stopped
# translate:
# image: hardcoreeng/translate
# extra_hosts:
# - 'huly.local:host-gateway'
# depends_on:
# redpanda:
# condition: service_started
# account:
# condition: service_started
# environment:
# - SECRET=secret
# - ACCOUNTS_URL=http://huly.local:3000
# - HULYLAKE_URL=http://huly.local:8096
# - QUEUE_CONFIG=${QUEUE_CONFIG}
# - QUEUE_REGION=cockroach
# - OPENAI_API_KEY=
# restart: unless-stopped
# translate:
# image: hardcoreeng/translate
# extra_hosts:
# - 'huly.local:host-gateway'
# depends_on:
# redpanda:
# condition: service_started
# account:
# condition: service_started
# environment:
# - SECRET=secret
# - ACCOUNTS_URL=http://huly.local:3000
# - HULYLAKE_URL=http://huly.local:8096
# - QUEUE_CONFIG=${QUEUE_CONFIG}
# - QUEUE_REGION=cockroach
# - OPENAI_API_KEY=
# restart: unless-stopped
backup-cockroach:
image: hardcoreeng/backup
extra_hosts:
@@ -629,6 +629,32 @@ services:
- STORAGE=minio|minio?accessKey=minioadmin&secretKey=minioadmin
- OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4318/v1/traces
restart: unless-stopped
rating_cockroach:
image: hardcoreeng/rating
extra_hosts:
- 'huly.local:host-gateway'
links:
- cockroach
- minio
- account
- stats
depends_on:
redpanda:
condition: service_started
environment:
- QUEUE_CONFIG=${QUEUE_CONFIG}
- REGION=cockroach
- SERVER_SECRET=secret
- STATS_URL=http://huly.local:4900
- DB_URL=${DB_CR_URL}
- STORAGE_CONFIG=${STORAGE_CONFIG}
- ACCOUNTS_URL=http://huly.local:3000
- COMMUNICATION_TIME_LOGGING_ENABLED=true
- COMMUNICATION_API_ENABLED=true
- OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4318/v1/traces
- HYLYLAKE_URL=http://huly.local:8096
restart: unless-stopped
jaeger:
image: jaegertracing/all-in-one:latest
extra_hosts:
+3
View File
@@ -289,6 +289,9 @@
"@hcengineering/inbox": "^0.7.0",
"@hcengineering/inbox-assets": "^0.7.0",
"@hcengineering/inbox-resources": "^0.7.0",
"@hcengineering/rating": "^0.7.0",
"@hcengineering/rating-assets": "^0.7.0",
"@hcengineering/rating-resources": "^0.7.0",
"readable-stream": "^4.7.0",
"svelte": "^4.2.20"
}
+7
View File
@@ -80,6 +80,7 @@ import { emojiId } from '@hcengineering/emoji'
import billingPlugin, { billingId } from '@hcengineering/billing'
import { hulyMailId } from '@hcengineering/huly-mail'
import { aiAssistantId } from '@hcengineering/ai-assistant'
import { ratingId } from '@hcengineering/rating'
import '@hcengineering/activity-assets'
import '@hcengineering/analytics-collector-assets'
@@ -139,6 +140,7 @@ import '@hcengineering/emoji-assets'
import '@hcengineering/billing-assets'
import '@hcengineering/huly-mail-assets'
import '@hcengineering/ai-assistant-assets'
import '@hcengineering/rating-assets'
import { coreId } from '@hcengineering/core'
import presentation, {
@@ -400,6 +402,7 @@ function configureI18n (): void {
aiAssistantId,
async (lang: string) => await import(`@hcengineering/ai-assistant-assets/lang/${lang}.json`)
)
addStringsLoader(ratingId, async (lang: string) => await import(`@hcengineering/rating-assets/lang/${lang}.json`))
}
export async function configurePlatform () {
@@ -680,6 +683,10 @@ export async function configurePlatform () {
inboxId,
async () => await import(/* webpackChunkName: "inbox" */ '@hcengineering/inbox-resources')
)
addLocation(
ratingId,
async () => await import(/* webpackChunkName: "rating" */ '@hcengineering/rating-resources')
)
setMetadata(client.metadata.FilterModel, 'ui')
setMetadata(client.metadata.ExtraPlugins, ['preference' as Plugin])
+4 -3
View File
@@ -21,9 +21,9 @@
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/tool staging",
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/tool",
"run-local-mongo": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret FULLTEXT_URL=http://localhost:4700 ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) QUEUE_CONFIG='localhost:19092' node --expose-gc --max-old-space-size=18000 ./bundle/bundle.js",
"run-local": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret FULLTEXT_URL=http://localhost:4702 ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3332 STORAGE_CONFIG='datalake|http://huly.local:4030' HULYLAKE_URL=http://huly.local:8096 ACCOUNT_DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 REGION_INFO='cockroach|CockroachDB' MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) QUEUE_CONFIG='localhost:19092' node --expose-gc --max-old-space-size=18000 $TOOL_OPT ./bundle/bundle.js",
"run-local": "(rush bundle --to @hcengineering/tool >/dev/null || true) && cross-env SERVER_SECRET=secret FULLTEXT_URL=http://localhost:4702 ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3332 STORAGE_CONFIG='datalake|http://huly.local:4030' HULYLAKE_URL=http://huly.local:8096 ACCOUNT_DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 REGION_INFO='cockroach|CockroachDB' MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) QUEUE_CONFIG='localhost:19092' node --expose-gc --max-old-space-size=18000 $TOOL_OPT ./bundle/bundle.js",
"run-local-brk": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --inspect-brk --enable-source-maps --max-old-space-size=18000 ./bundle/bundle.js",
"run": "rush bundle --to @hcengineering/tool >/dev/null && cross-env node --max-old-space-size=8000 ./bundle/bundle.js",
"run": "(rush bundle --to @hcengineering/tool >/dev/null || true ) && cross-env node --max-old-space-size=8000 ./bundle/bundle.js",
"upgrade-mongo": "rushx run-local-mongo upgrade-workspace -- $1",
"upgrade": "rushx run-local upgrade-workspace -- $1",
"upgrade-brk": "rushx run-local-brk upgrade-workspace -- $1",
@@ -183,6 +183,7 @@
"@hcengineering/api-client": "^0.7.5",
"@faker-js/faker": "^8.4.1",
"@hcengineering/hulylake-client": "^0.7.6",
"@hcengineering/communication-types": "^0.7.7"
"@hcengineering/communication-types": "^0.7.7",
"@hcengineering/pod-rating": "^0.7.0"
}
}
+56 -20
View File
@@ -27,16 +27,29 @@ import accountPlugin, {
type AccountDB,
type Workspace
} from '@hcengineering/account'
import {
getMongoAccountDB,
type Account as OldAccount,
type Workspace as OldWorkspace
} from '@hcengineering/account-service'
import { getWorkspaceClient as getHulylakeClient } from '@hcengineering/hulylake-client'
import { setMetadata } from '@hcengineering/platform'
import {
createPostgreeDestroyAdapter,
createPostgresAdapter,
createPostgresTxAdapter,
getDBClient,
shutdownPostgres
} from '@hcengineering/postgres'
import {
backup,
backupDownload,
backupFind,
checkBackupIntegrity,
compactBackup,
createFileBackupStorage,
createStorageBackupStorage,
restore,
backupDownload
restore
} from '@hcengineering/server-backup'
import serverClientPlugin, { getAccountClient, getTransactorEndpoint } from '@hcengineering/server-client'
import {
@@ -51,19 +64,6 @@ import {
} from '@hcengineering/server-pipeline'
import serverToken, { decodeToken, generateToken } from '@hcengineering/server-token'
import { createWorkspace, upgradeWorkspace } from '@hcengineering/workspace-service'
import {
getMongoAccountDB,
type Account as OldAccount,
type Workspace as OldWorkspace
} from '@hcengineering/account-service'
import { getWorkspaceClient as getHulylakeClient } from '@hcengineering/hulylake-client'
import {
getDBClient,
createPostgreeDestroyAdapter,
createPostgresAdapter,
createPostgresTxAdapter,
shutdownPostgres
} from '@hcengineering/postgres'
import { faker } from '@faker-js/faker'
import { getPlatformQueue } from '@hcengineering/kafka'
@@ -71,13 +71,14 @@ import { buildStorageFromConfig, createStorageFromConfig, storageConfigFromEnv }
import { program, type Command } from 'commander'
import { updateField } from './workspace'
import { RatingCalculator, ratingEvents, type QueueRatingMessage } from '@hcengineering/pod-rating'
import {
AccountRole,
isArchivingMode,
isDeletingMode,
MeasureMetricsContext,
metricsToString,
SocialId,
SocialIdType,
systemAccountEmail,
systemAccountUuid,
@@ -85,12 +86,12 @@ import {
type Data,
type Doc,
type PersonId,
type PersonUuid,
type Ref,
type Tx,
type Version,
type WorkspaceDataId,
type WorkspaceUuid,
type PersonUuid
type WorkspaceUuid
} from '@hcengineering/core'
import { consoleModelLogger, type MigrateOperation } from '@hcengineering/model'
import {
@@ -129,14 +130,14 @@ import { performGmailAccountMigrations } from './gmail'
import { getToolToken, getWorkspace, getWorkspaceTransactorEndpoint } from './utils'
import { createRestClient } from '@hcengineering/api-client'
import { type CardID } from '@hcengineering/communication-types'
import { sendTransactorEvent } from '@hcengineering/server-tool'
import { existsSync } from 'fs'
import { mkdir, writeFile } from 'fs/promises'
import { dirname } from 'path'
import { migrateWorkspaceMessages } from './communication'
import { restoreMarkupRefs } from './markup'
import { restoreGithubIntegrations } from './restoreGithub'
import { migrateWorkspaceMessages } from './communication'
import { type CardID } from '@hcengineering/communication-types'
const colorConstants = {
colorRed: '\u001b[31m',
@@ -2899,6 +2900,41 @@ export function devTool (
}, dbUrl)
})
program
.command('calculate-ratings <workspace>')
.description('Perform a rating re-calculation')
.option('-q <queue>', 'Send to queue', false)
.option('-r, --region <region>', 'Region')
.action(async (workspace: string, cmd: { queue: boolean | undefined, region: string | undefined }) => {
await withAccountDatabase(async (db) => {
const { txes, dbUrl } = prepareTools()
const ws = await getWorkspace(db, workspace)
if (ws === null) {
throw new Error(`workspace ${workspace} not found`)
}
if (cmd.queue === true) {
const queue = getPlatformQueue('tool', cmd.region ?? '')
const ratingQueue = queue.getProducer<QueueRatingMessage>(toolCtx, 'rating')
await ratingQueue.send(toolCtx, ws.uuid, [ratingEvents.reindex()])
await queue.shutdown()
} else {
const wsIds = {
uuid: ws.uuid,
dataId: ws.dataId,
url: ws.url
}
const calculator = await RatingCalculator.create(toolCtx, txes, wsIds, dbUrl, async () => '')
await calculator.recalculateAll(toolCtx)
await calculator.close()
}
})
})
extendProgram?.(program)
process.on('unhandledRejection', (reason, promise) => {