Skip to content

Commit abc7a60

Browse files
committed
Merge remote-tracking branch 'origin/develop' into staging
Signed-off-by: Andrey Sobolev <[email protected]>
2 parents 2a4c326 + f89df59 commit abc7a60

File tree

140 files changed

+1989
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+1989
-394
lines changed

.github/issue_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
A clear and concise description of the issue.
33

44
### Your environment
5-
* Version of huly
5+
* Version of Huly
66
* Browser (and version)
77
* Your operating system (and version)
88

.vscode/launch.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@
9595
"ACCOUNT_PORT": "3000",
9696
"FRONT_URL": "http://localhost:8080",
9797
"SES_URL": "",
98+
// "WS_LIVENESS_DAYS": "1",
9899
"MINIO_ACCESS_KEY": "minioadmin",
99100
"MINIO_SECRET_KEY": "minioadmin",
100-
"MINIO_ENDPOINT": "localhost"
101+
"MINIO_ENDPOINT": "localhost",
102+
// "DISABLE_SIGNUP": "true",
101103
// "INIT_SCRIPT_URL": "https://raw.githubusercontent.com/hcengineering/init/main/script.yaml",
102104
// "INIT_WORKSPACE": "onboarding",
103105
},

dev/docker-compose.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ services:
8383
- RESERVED_DB_NAMES=telegram,gmail,github
8484
- MODEL_ENABLED=*
8585
- LAST_NAME_FIRST=true
86+
# - WS_LIVENESS_DAYS=1
8687
- ACCOUNTS_URL=http://host.docker.internal:3000
8788
- BRANDING_PATH=/var/cfg/branding.json
89+
# - DISABLE_SIGNUP=true
8890
# - INIT_SCRIPT_URL=https://raw.githubusercontent.com/hcengineering/init/main/script.yaml
8991
# - INIT_WORKSPACE=onboarding
9092
restart: unless-stopped
@@ -197,6 +199,7 @@ services:
197199
- DESKTOP_UPDATES_URL=https://dist.huly.io
198200
- DESKTOP_UPDATES_CHANNEL=dev
199201
- BRANDING_URL=http://host.docker.internal:8087/branding.json
202+
# - DISABLE_SIGNUP=true
200203
restart: unless-stopped
201204
transactor:
202205
image: hardcoreeng/transactor

dev/tool/src/db.ts

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export async function moveFromMongoToPG (
5454
client.close()
5555
}
5656

57+
function escapeBackticks (str: string): string {
58+
return str.replaceAll("'", "''")
59+
}
60+
5761
async function moveWorkspace (
5862
accountDb: AccountDB,
5963
mongo: MongoClient,
@@ -77,32 +81,38 @@ async function moveWorkspace (
7781
for (const collection of collections) {
7882
const cursor = collection.find()
7983
const domain = translateDomain(collection.collectionName)
84+
const current = await pgClient.query(`SELECT _id FROM ${domain} WHERE "workspaceId" = $1`, [ws.workspace])
85+
const currentIds = new Set(current.rows.map((r) => r._id))
8086
console.log('move domain', domain)
87+
const docs: Doc[] = []
8188
while (true) {
82-
const doc = (await cursor.next()) as Doc | null
83-
if (doc === null) break
84-
try {
85-
const converted = convertDoc(doc, ws.workspaceName ?? ws.workspace)
86-
await retryTxn(pgClient, async (client) => {
87-
await client.query(
88-
`INSERT INTO ${domain} (_id, "workspaceId", _class, "createdBy", "modifiedBy", "modifiedOn", "createdOn", space, "attachedTo", data) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`,
89-
[
90-
converted._id,
91-
converted.workspaceId,
92-
converted._class,
93-
converted.createdBy ?? converted.modifiedBy,
94-
converted.modifiedBy,
95-
converted.modifiedOn,
96-
converted.createdOn ?? converted.modifiedOn,
97-
converted.space,
98-
converted.attachedTo,
99-
converted.data
100-
]
101-
)
102-
})
103-
} catch (err) {
104-
console.log('error when move doc', doc._id, doc._class, err)
105-
continue
89+
while (docs.length < 50000) {
90+
const doc = (await cursor.next()) as Doc | null
91+
if (doc === null) break
92+
if (currentIds.has(doc._id)) continue
93+
docs.push(doc)
94+
}
95+
if (docs.length === 0) break
96+
while (docs.length > 0) {
97+
const part = docs.splice(0, 500)
98+
const vals = part
99+
.map((doc) => {
100+
const d = convertDoc(doc, ws.workspace)
101+
return `('${d._id}', '${d.workspaceId}', '${d._class}', '${d.createdBy ?? d.modifiedBy}', '${d.modifiedBy}', ${d.modifiedOn}, ${d.createdOn ?? d.modifiedOn}, '${d.space}', ${
102+
d.attachedTo != null ? `'${d.attachedTo}'` : 'NULL'
103+
}, '${escapeBackticks(JSON.stringify(d.data))}')`
104+
})
105+
.join(', ')
106+
try {
107+
await retryTxn(pgClient, async (client) => {
108+
await client.query(
109+
`INSERT INTO ${translateDomain(domain)} (_id, "workspaceId", _class, "createdBy", "modifiedBy", "modifiedOn", "createdOn", space, "attachedTo", data) VALUES ${vals}`
110+
)
111+
})
112+
} catch (err) {
113+
console.log('error when move doc to', domain, err)
114+
continue
115+
}
106116
}
107117
}
108118
}

dev/tool/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ export function devTool (
15981598
throw new Error('mongodbUri is not set')
15991599
}
16001600

1601-
await withDatabase(dbUrl, async (db) => {
1601+
await withDatabase(mongodbUri, async (db) => {
16021602
const workspaces = await listWorkspacesRaw(db)
16031603
workspaces.sort((a, b) => b.lastVisit - a.lastVisit)
16041604
await moveFromMongoToPG(
@@ -1617,7 +1617,7 @@ export function devTool (
16171617
throw new Error('mongodbUri is not set')
16181618
}
16191619

1620-
await withDatabase(dbUrl, async (db) => {
1620+
await withDatabase(mongodbUri, async (db) => {
16211621
const workspaceInfo = await getWorkspaceById(db, workspace)
16221622
if (workspaceInfo === null) {
16231623
throw new Error(`workspace ${workspace} not found`)

dev/tool/src/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export async function recreateElastic (
112112
const db = getWorkspaceMongoDB(_client, workspaceId)
113113
await db
114114
.collection(DOMAIN_DOC_INDEX_STATE)
115-
.updateMany({ _class: core.class.DocIndexState }, { $set: { stages: {} } })
115+
.updateMany({ _class: core.class.DocIndexState }, { $set: { stages: {}, needIndex: true } })
116116
await connection.sendForceClose()
117117
} finally {
118118
client.close()

models/contact/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ export function createModel (builder: Builder): void {
955955
)
956956

957957
// Allow to use fuzzy search for mixins
958-
builder.mixin(contact.class.Contact, core.class.Class, core.mixin.FullTextSearchContext, {
958+
builder.createDoc(core.class.FullTextSearchContext, core.space.Model, {
959+
toClass: contact.class.Contact,
959960
fullTextSummary: true
960961
})
961962

models/controlled-documents/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ export function createModel (builder: Builder): void {
549549
func: documents.function.GetAllDocumentStates
550550
})
551551

552-
builder.mixin(documents.class.Document, core.class.Class, core.mixin.FullTextSearchContext, {
552+
builder.createDoc(core.class.FullTextSearchContext, core.space.Model, {
553+
toClass: documents.class.Document,
553554
fullTextSummary: true,
554555
childProcessingAllowed: true
555556
})
@@ -886,11 +887,13 @@ export function defineNotifications (builder: Builder): void {
886887
}
887888

888889
export function defineSearch (builder: Builder): void {
889-
builder.mixin(documents.class.Document, core.class.Class, core.mixin.FullTextSearchContext, {
890+
builder.createDoc(core.class.FullTextSearchContext, core.space.Model, {
891+
toClass: documents.class.Document,
890892
parentPropagate: true
891893
})
892894

893-
builder.mixin(documents.class.DocumentMeta, core.class.Class, core.mixin.FullTextSearchContext, {
895+
builder.createDoc(core.class.FullTextSearchContext, core.space.Model, {
896+
toClass: documents.class.DocumentMeta,
894897
fullTextSummary: true,
895898
childProcessingAllowed: true,
896899
propagate: []

models/core/src/core.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,10 @@ export class TDocIndexState extends TDoc implements DocIndexState {
361361
generationId?: string
362362
}
363363

364-
@MMixin(core.mixin.FullTextSearchContext, core.class.Class)
365-
export class TFullTextSearchContext extends TClass implements FullTextSearchContext {}
364+
@Model(core.class.FullTextSearchContext, core.class.Doc, DOMAIN_MODEL)
365+
export class TFullTextSearchContext extends TDoc implements FullTextSearchContext {
366+
toClass!: Ref<Class<Doc<Space>>>
367+
}
366368

367369
@MMixin(core.mixin.ConfigurationElement, core.class.Class)
368370
export class TConfigurationElement extends TClass implements ConfigurationElement {

models/core/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ export function createModel (builder: Builder): void {
309309
]
310310
})
311311

312-
builder.mixin(core.class.Space, core.class.Class, core.mixin.FullTextSearchContext, {
312+
builder.createDoc(core.class.FullTextSearchContext, core.space.Model, {
313+
toClass: core.class.Space,
313314
childProcessingAllowed: false
314315
})
315316

0 commit comments

Comments
 (0)