mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-25 19:58:30 +03:00
UBER-218: Fix createOn -> createdOn (#3266)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
9d037b79f5
commit
4fad67b6a4
@ -137,7 +137,7 @@ export async function migrateThreadMessages (client: MigrationClient): Promise<v
|
|||||||
modifiedOn: message.modifiedOn,
|
modifiedOn: message.modifiedOn,
|
||||||
modifiedBy: message.modifiedBy,
|
modifiedBy: message.modifiedBy,
|
||||||
createBy: message.modifiedBy,
|
createBy: message.modifiedBy,
|
||||||
createOn: message.modifiedOn,
|
createdOn: message.modifiedOn,
|
||||||
_id: message._id as string as Ref<ThreadMessage>
|
_id: message._id as string as Ref<ThreadMessage>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ export async function migrateThreadMessages (client: MigrationClient): Promise<v
|
|||||||
{
|
{
|
||||||
objectClass: chunter.class.ThreadMessage,
|
objectClass: chunter.class.ThreadMessage,
|
||||||
'attributes.createBy': tx.modifiedBy,
|
'attributes.createBy': tx.modifiedBy,
|
||||||
'attributes.createOn': tx.modifiedOn,
|
'attributes.createdOn': tx.modifiedOn,
|
||||||
'attributes.content': tx.attributes.message
|
'attributes.content': tx.attributes.message
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -105,7 +105,7 @@ export class TDoc extends TObj implements Doc {
|
|||||||
|
|
||||||
@Prop(TypeTimestamp(), core.string.CreatedDate)
|
@Prop(TypeTimestamp(), core.string.CreatedDate)
|
||||||
@ReadOnly()
|
@ReadOnly()
|
||||||
createOn!: Timestamp
|
createdOn!: Timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Model(core.class.AttachedDoc, core.class.Doc)
|
@Model(core.class.AttachedDoc, core.class.Doc)
|
||||||
|
@ -99,6 +99,9 @@ async function fillCreatedOn (client: MigrationClient): Promise<void> {
|
|||||||
) {
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await client.update<Doc>(domain, { createOn: { $exists: true } }, { $unset: { createOn: 1 } })
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
const objects = await client.find<Doc>(
|
const objects = await client.find<Doc>(
|
||||||
@ -115,7 +118,7 @@ async function fillCreatedOn (client: MigrationClient): Promise<void> {
|
|||||||
_class: core.class.TxCreateDoc,
|
_class: core.class.TxCreateDoc,
|
||||||
objectId: { $in: Array.from(objects.map((it) => it._id)) }
|
objectId: { $in: Array.from(objects.map((it) => it._id)) }
|
||||||
},
|
},
|
||||||
{ projection: { _id: 1, modifiedOn: 1, createOn: 1, objectId: 1 } }
|
{ projection: { _id: 1, modifiedOn: 1, createdOn: 1, objectId: 1 } }
|
||||||
)
|
)
|
||||||
|
|
||||||
const txes2 = (
|
const txes2 = (
|
||||||
@ -126,13 +129,13 @@ async function fillCreatedOn (client: MigrationClient): Promise<void> {
|
|||||||
'tx._class': core.class.TxCreateDoc,
|
'tx._class': core.class.TxCreateDoc,
|
||||||
'tx.objectId': { $in: Array.from(objects.map((it) => it._id)) }
|
'tx.objectId': { $in: Array.from(objects.map((it) => it._id)) }
|
||||||
},
|
},
|
||||||
{ projection: { _id: 1, modifiedOn: 1, createOn: 1, tx: 1 } }
|
{ projection: { _id: 1, modifiedOn: 1, createdOn: 1, tx: 1 } }
|
||||||
)
|
)
|
||||||
).map((it) => it.tx as unknown as TxCreateDoc<Doc>)
|
).map((it) => it.tx as unknown as TxCreateDoc<Doc>)
|
||||||
|
|
||||||
const txMap = new Map(txes.concat(txes2).map((p) => [p.objectId, p]))
|
const txMap = new Map(txes.concat(txes2).map((p) => [p.objectId, p]))
|
||||||
|
|
||||||
console.log('migrateCreateOn', domain, objects.length)
|
console.log('migratecreatedOn', domain, objects.length)
|
||||||
await client.bulk(
|
await client.bulk(
|
||||||
domain,
|
domain,
|
||||||
objects.map((it) => {
|
objects.map((it) => {
|
||||||
@ -140,7 +143,7 @@ async function fillCreatedOn (client: MigrationClient): Promise<void> {
|
|||||||
return {
|
return {
|
||||||
filter: { _id: it._id },
|
filter: { _id: it._id },
|
||||||
update: {
|
update: {
|
||||||
createdOn: createTx?.createOn ?? it.modifiedOn
|
createdOn: createTx?.createdOn ?? it.modifiedOn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -263,7 +263,7 @@ export function createModel (builder: Builder): void {
|
|||||||
orderBy: [
|
orderBy: [
|
||||||
['state', SortingOrder.Ascending],
|
['state', SortingOrder.Ascending],
|
||||||
['modifiedOn', SortingOrder.Descending],
|
['modifiedOn', SortingOrder.Descending],
|
||||||
['createOn', SortingOrder.Descending],
|
['createdOn', SortingOrder.Descending],
|
||||||
['dueDate', SortingOrder.Ascending],
|
['dueDate', SortingOrder.Ascending],
|
||||||
['rank', SortingOrder.Ascending]
|
['rank', SortingOrder.Ascending]
|
||||||
],
|
],
|
||||||
|
@ -624,7 +624,7 @@ export function createModel (builder: Builder): void {
|
|||||||
orderBy: [
|
orderBy: [
|
||||||
['state', SortingOrder.Ascending],
|
['state', SortingOrder.Ascending],
|
||||||
['modifiedOn', SortingOrder.Descending],
|
['modifiedOn', SortingOrder.Descending],
|
||||||
['createOn', SortingOrder.Descending],
|
['createdOn', SortingOrder.Descending],
|
||||||
['dueDate', SortingOrder.Ascending],
|
['dueDate', SortingOrder.Ascending],
|
||||||
['rank', SortingOrder.Ascending]
|
['rank', SortingOrder.Ascending]
|
||||||
],
|
],
|
||||||
|
@ -463,7 +463,7 @@ export function createModel (builder: Builder): void {
|
|||||||
['status', SortingOrder.Ascending],
|
['status', SortingOrder.Ascending],
|
||||||
['priority', SortingOrder.Ascending],
|
['priority', SortingOrder.Ascending],
|
||||||
['modifiedOn', SortingOrder.Descending],
|
['modifiedOn', SortingOrder.Descending],
|
||||||
['createOn', SortingOrder.Descending],
|
['createdOn', SortingOrder.Descending],
|
||||||
['dueDate', SortingOrder.Ascending],
|
['dueDate', SortingOrder.Ascending],
|
||||||
['rank', SortingOrder.Ascending]
|
['rank', SortingOrder.Ascending]
|
||||||
],
|
],
|
||||||
@ -592,7 +592,7 @@ export function createModel (builder: Builder): void {
|
|||||||
['status', SortingOrder.Ascending],
|
['status', SortingOrder.Ascending],
|
||||||
['priority', SortingOrder.Ascending],
|
['priority', SortingOrder.Ascending],
|
||||||
['modifiedOn', SortingOrder.Descending],
|
['modifiedOn', SortingOrder.Descending],
|
||||||
['createOn', SortingOrder.Descending],
|
['createdOn', SortingOrder.Descending],
|
||||||
['dueDate', SortingOrder.Ascending]
|
['dueDate', SortingOrder.Ascending]
|
||||||
],
|
],
|
||||||
groupDepth: 1,
|
groupDepth: 1,
|
||||||
@ -1780,7 +1780,7 @@ export function createModel (builder: Builder): void {
|
|||||||
orderBy: [
|
orderBy: [
|
||||||
['modifiedOn', SortingOrder.Descending],
|
['modifiedOn', SortingOrder.Descending],
|
||||||
['targetDate', SortingOrder.Descending],
|
['targetDate', SortingOrder.Descending],
|
||||||
['createOn', SortingOrder.Descending]
|
['createdOn', SortingOrder.Descending]
|
||||||
],
|
],
|
||||||
other: [showColors]
|
other: [showColors]
|
||||||
}
|
}
|
||||||
@ -1852,7 +1852,7 @@ export function createModel (builder: Builder): void {
|
|||||||
groupBy: ['lead'],
|
groupBy: ['lead'],
|
||||||
orderBy: [
|
orderBy: [
|
||||||
['modifiedOn', SortingOrder.Descending],
|
['modifiedOn', SortingOrder.Descending],
|
||||||
['createOn', SortingOrder.Descending]
|
['createdOn', SortingOrder.Descending]
|
||||||
],
|
],
|
||||||
other: [showColors]
|
other: [showColors]
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ async function migrateViewletPreference (client: MigrationClient): Promise<void>
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function migrateSavedFilters (client: MigrationClient): Promise<void> {
|
async function migrateSavedFilters (client: MigrationClient): Promise<void> {
|
||||||
|
try {
|
||||||
await client.move(
|
await client.move(
|
||||||
DOMAIN_PREFERENCE,
|
DOMAIN_PREFERENCE,
|
||||||
{
|
{
|
||||||
@ -66,6 +67,9 @@ async function migrateSavedFilters (client: MigrationClient): Promise<void> {
|
|||||||
},
|
},
|
||||||
DOMAIN_VIEW
|
DOMAIN_VIEW
|
||||||
)
|
)
|
||||||
|
} catch (err: any) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
const preferences = await client.find<FilteredView>(DOMAIN_VIEW, {
|
const preferences = await client.find<FilteredView>(DOMAIN_VIEW, {
|
||||||
_class: view.class.FilteredView,
|
_class: view.class.FilteredView,
|
||||||
users: { $exists: false }
|
users: { $exists: false }
|
||||||
|
@ -57,7 +57,7 @@ export interface Doc extends Obj {
|
|||||||
modifiedOn: Timestamp
|
modifiedOn: Timestamp
|
||||||
modifiedBy: Ref<Account>
|
modifiedBy: Ref<Account>
|
||||||
createdBy?: Ref<Account> // Marked as optional since it will be filled by platform.
|
createdBy?: Ref<Account> // Marked as optional since it will be filled by platform.
|
||||||
createOn?: Timestamp // Marked as optional since it will be filled by platform.
|
createdOn?: Timestamp // Marked as optional since it will be filled by platform.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -354,7 +354,7 @@ export abstract class TxProcessor implements WithTx {
|
|||||||
modifiedBy: tx.modifiedBy,
|
modifiedBy: tx.modifiedBy,
|
||||||
modifiedOn: tx.modifiedOn,
|
modifiedOn: tx.modifiedOn,
|
||||||
createdBy: tx.createdBy ?? tx.modifiedBy,
|
createdBy: tx.createdBy ?? tx.modifiedBy,
|
||||||
createOn: tx.createOn ?? tx.modifiedOn
|
createdOn: tx.createdOn ?? tx.modifiedOn
|
||||||
} as T
|
} as T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
if (docUpdate === undefined || lastView === undefined) return -1
|
if (docUpdate === undefined || lastView === undefined) return -1
|
||||||
for (let index = 0; index < messages.length; index++) {
|
for (let index = 0; index < messages.length; index++) {
|
||||||
const message = messages[index]
|
const message = messages[index]
|
||||||
if ((message.createOn ?? 0) >= lastView) return index
|
if ((message.createdOn ?? 0) >= lastView) return index
|
||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
@ -209,8 +209,8 @@
|
|||||||
{#if newMessagesPos === i}
|
{#if newMessagesPos === i}
|
||||||
<ChannelSeparator title={chunter.string.New} line reverse isNew />
|
<ChannelSeparator title={chunter.string.New} line reverse isNew />
|
||||||
{/if}
|
{/if}
|
||||||
{#if i === 0 || isOtherDay(message.createOn ?? 0, messages[i - 1].createOn ?? 0)}
|
{#if i === 0 || isOtherDay(message.createdOn ?? 0, messages[i - 1].createdOn ?? 0)}
|
||||||
<JumpToDateSelector selectedDate={message.createOn} on:jumpToDate={handleJumpToDate} />
|
<JumpToDateSelector selectedDate={message.createdOn} on:jumpToDate={handleJumpToDate} />
|
||||||
{/if}
|
{/if}
|
||||||
<MessageComponent
|
<MessageComponent
|
||||||
isHighlighted={$messageIdForScroll === message._id && $isMessageHighlighted}
|
isHighlighted={$messageIdForScroll === message._id && $isMessageHighlighted}
|
||||||
|
@ -228,7 +228,7 @@
|
|||||||
{#if employee}
|
{#if employee}
|
||||||
<EmployeePresenter value={employee} shouldShowAvatar={false} inline />
|
<EmployeePresenter value={employee} shouldShowAvatar={false} inline />
|
||||||
{/if}
|
{/if}
|
||||||
<span>{getTime(message.createOn ?? 0)}</span>
|
<span>{getTime(message.createdOn ?? 0)}</span>
|
||||||
{#if message.editedOn}
|
{#if message.editedOn}
|
||||||
<span use:tooltip={{ label: ui.string.TimeTooltip, props: { value: getTime(message.editedOn) } }}>
|
<span use:tooltip={{ label: ui.string.TimeTooltip, props: { value: getTime(message.editedOn) } }}>
|
||||||
<Label label={chunter.string.Edited} />
|
<Label label={chunter.string.Edited} />
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
...resultQuery
|
...resultQuery
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sort: { createOn: SortingOrder.Descending },
|
sort: { createdOn: SortingOrder.Descending },
|
||||||
limit: 100,
|
limit: 100,
|
||||||
lookup: {
|
lookup: {
|
||||||
_id: { attachments: attachment.class.Attachment },
|
_id: { attachments: attachment.class.Attachment },
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<MessageViewer message={message.content} />
|
<MessageViewer message={message.content} />
|
||||||
<span class="time">{getTime(message.createOn ?? 0)}</span>
|
<span class="time">{getTime(message.createdOn ?? 0)}</span>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
const options: FindOptions<ThreadMessage> = {
|
const options: FindOptions<ThreadMessage> = {
|
||||||
lookup,
|
lookup,
|
||||||
sort: {
|
sort: {
|
||||||
createOn: SortingOrder.Descending
|
createdOn: SortingOrder.Descending
|
||||||
},
|
},
|
||||||
total: true
|
total: true
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@
|
|||||||
if (docUpdate === undefined || lastView === undefined) return -1
|
if (docUpdate === undefined || lastView === undefined) return -1
|
||||||
for (let index = 0; index < comments.length; index++) {
|
for (let index = 0; index < comments.length; index++) {
|
||||||
const comment = comments[index]
|
const comment = comments[index]
|
||||||
if ((comment.createOn ?? 0) >= lastView) return index
|
if ((comment.createdOn ?? 0) >= lastView) return index
|
||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
sort: {
|
sort: {
|
||||||
createOn: SortingOrder.Descending
|
createdOn: SortingOrder.Descending
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
...resultQuery
|
...resultQuery
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sort: { createOn: SortingOrder.Descending },
|
sort: { createdOn: SortingOrder.Descending },
|
||||||
limit: 100,
|
limit: 100,
|
||||||
lookup: { _id: { statuses: contact.class.Status } }
|
lookup: { _id: { statuses: contact.class.Status } }
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@
|
|||||||
$: resultChannels = mergeChannels(oldChannels, targetChannels, enabledChannels)
|
$: resultChannels = mergeChannels(oldChannels, targetChannels, enabledChannels)
|
||||||
|
|
||||||
const attributes = hierarchy.getAllAttributes(contact.class.Employee, core.class.Doc)
|
const attributes = hierarchy.getAllAttributes(contact.class.Employee, core.class.Doc)
|
||||||
const ignoreKeys = ['name', 'avatar', 'createOn']
|
const ignoreKeys = ['name', 'avatar', 'createdOn']
|
||||||
const objectAttributes = Array.from(attributes.entries()).filter(
|
const objectAttributes = Array.from(attributes.entries()).filter(
|
||||||
(p) => !p[1].hidden && !ignoreKeys.includes(p[0]) && !isCollectionAttr(hierarchy, { key: p[0], attr: p[1] })
|
(p) => !p[1].hidden && !ignoreKeys.includes(p[0]) && !isCollectionAttr(hierarchy, { key: p[0], attr: p[1] })
|
||||||
)
|
)
|
||||||
|
@ -54,7 +54,9 @@
|
|||||||
'tx.attributes.incoming': false
|
'tx.attributes.incoming': false
|
||||||
},
|
},
|
||||||
(res) => {
|
(res) => {
|
||||||
const filtered = res.filter((p) => (p.tx as TxCreateDoc<ChannelItem>).attributes.sendOn >= (object.createOn ?? 0))
|
const filtered = res.filter(
|
||||||
|
(p) => (p.tx as TxCreateDoc<ChannelItem>).attributes.sendOn >= (object.createdOn ?? 0)
|
||||||
|
)
|
||||||
newTxes = createDisplayTxes(filtered)
|
newTxes = createDisplayTxes(filtered)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -187,7 +187,7 @@
|
|||||||
|
|
||||||
// Store all extra values.
|
// Store all extra values.
|
||||||
for (const [k, v] of Object.entries(object)) {
|
for (const [k, v] of Object.entries(object)) {
|
||||||
if (v != null && k !== 'createOn' && k !== 'avatar') {
|
if (v != null && k !== 'createdOn' && k !== 'avatar') {
|
||||||
const attr = hierarchy.findAttribute(recruit.mixin.Candidate, k)
|
const attr = hierarchy.findAttribute(recruit.mixin.Candidate, k)
|
||||||
if (attr === undefined) continue
|
if (attr === undefined) continue
|
||||||
if (attr.attributeOf === recruit.mixin.Candidate) {
|
if (attr.attributeOf === recruit.mixin.Candidate) {
|
||||||
|
@ -184,7 +184,8 @@ async function ThreadMessageDelete (tx: Tx, control: TriggerControl): Promise<Tx
|
|||||||
comment.attachedTo,
|
comment.attachedTo,
|
||||||
{
|
{
|
||||||
replies: comments.map((comm) => (control.modelDb.getObject(comm.createBy) as EmployeeAccount).employee),
|
replies: comments.map((comm) => (control.modelDb.getObject(comm.createBy) as EmployeeAccount).employee),
|
||||||
lastReply: comments.length > 0 ? Math.max(...comments.map((comm) => comm.createOn ?? comm.modifiedOn)) : undefined
|
lastReply:
|
||||||
|
comments.length > 0 ? Math.max(...comments.map((comm) => comm.createdOn ?? comm.modifiedOn)) : undefined
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ export async function IsIncomingMessage (
|
|||||||
control: TriggerControl
|
control: TriggerControl
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const message = TxProcessor.createDoc2Doc(TxProcessor.extractTx(tx) as TxCreateDoc<Message>)
|
const message = TxProcessor.createDoc2Doc(TxProcessor.extractTx(tx) as TxCreateDoc<Message>)
|
||||||
return message.incoming && message.sendOn > (doc.createOn ?? doc.modifiedOn)
|
return message.incoming && message.sendOn > (doc.createdOn ?? doc.modifiedOn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||||
|
@ -125,7 +125,7 @@ export async function IsIncomingMessage (
|
|||||||
control: TriggerControl
|
control: TriggerControl
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const message = TxProcessor.createDoc2Doc(TxProcessor.extractTx(tx) as TxCreateDoc<TelegramMessage>)
|
const message = TxProcessor.createDoc2Doc(TxProcessor.extractTx(tx) as TxCreateDoc<TelegramMessage>)
|
||||||
return message.incoming && message.sendOn > (doc.createOn ?? doc.modifiedOn)
|
return message.incoming && message.sendOn > (doc.createdOn ?? doc.modifiedOn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||||
|
@ -37,7 +37,7 @@ export class ModifiedMiddleware extends BaseMiddleware implements Middleware {
|
|||||||
async tx (ctx: SessionContext, tx: Tx): Promise<TxMiddlewareResult> {
|
async tx (ctx: SessionContext, tx: Tx): Promise<TxMiddlewareResult> {
|
||||||
if (tx.modifiedBy !== core.account.System) {
|
if (tx.modifiedBy !== core.account.System) {
|
||||||
tx.modifiedOn = Date.now()
|
tx.modifiedOn = Date.now()
|
||||||
tx.createOn = tx.createOn ?? tx.modifiedOn
|
tx.createdOn = tx.createdOn ?? tx.modifiedOn
|
||||||
}
|
}
|
||||||
return await this.provideTx(ctx, tx)
|
return await this.provideTx(ctx, tx)
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ export const doc1: Task = {
|
|||||||
rate: 20,
|
rate: 20,
|
||||||
modifiedBy: 'user' as Ref<Account>,
|
modifiedBy: 'user' as Ref<Account>,
|
||||||
modifiedOn: 10,
|
modifiedOn: 10,
|
||||||
// createOn: 10,
|
// createdOn: 10,
|
||||||
space: '' as Ref<Space>
|
space: '' as Ref<Space>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user