New Activity - squashed (#4032)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
Co-authored-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Kristina
2023-12-11 18:54:36 +07:00
committed by GitHub
co-authored by Andrey Sobolev
parent 119d65653a
commit ea3eb4af83
212 changed files with 7611 additions and 3159 deletions
+13 -5
View File
@@ -1,5 +1,5 @@
import chunter, { Comment } from '@hcengineering/chunter'
import { AttachedData, Class, Doc, generateId, Ref, Space, TxOperations } from '@hcengineering/core'
import notification, { ChatMessage } from '@hcengineering/notification'
import faker from 'faker'
export interface CommentOptions {
@@ -20,17 +20,25 @@ export async function addComments<T extends Doc> (
): Promise<void> {
const commentsCount = options.min + faker.datatype.number(options.max)
for (let i = 0; i < commentsCount; i++) {
const commentId = `candidate-comment-${generateId()}-${i}` as Ref<Comment>
const commentId = `candidate-comment-${generateId()}-${i}` as Ref<ChatMessage>
const commentData: AttachedData<Comment> = {
const commentData: AttachedData<ChatMessage> = {
message: faker.lorem.paragraphs(options.paragraphMin + faker.datatype.number(options.paragraphMax))
}
await client.addCollection(chunter.class.Comment, space, objectId, _class, collection, commentData, commentId)
await client.addCollection(
notification.class.ChatMessage,
space,
objectId,
_class,
collection,
commentData,
commentId
)
if (faker.datatype.number(100) > options.updateFactor) {
const updateMsg = faker.lorem.paragraphs(options.paragraphMin + faker.datatype.number(options.paragraphMax))
await client.updateCollection(chunter.class.Comment, space, commentId, objectId, _class, collection, {
await client.updateCollection(notification.class.ChatMessage, space, commentId, objectId, _class, collection, {
message: updateMsg
})
}