UBER-218: Fix createOn -> createdOn (#3266)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-05-27 13:02:11 +07:00 committed by GitHub
parent 9d037b79f5
commit 4fad67b6a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 50 additions and 40 deletions

View File

@ -137,7 +137,7 @@ export async function migrateThreadMessages (client: MigrationClient): Promise<v
modifiedOn: message.modifiedOn,
modifiedBy: message.modifiedBy,
createBy: message.modifiedBy,
createOn: message.modifiedOn,
createdOn: message.modifiedOn,
_id: message._id as string as Ref<ThreadMessage>
})
}
@ -156,7 +156,7 @@ export async function migrateThreadMessages (client: MigrationClient): Promise<v
{
objectClass: chunter.class.ThreadMessage,
'attributes.createBy': tx.modifiedBy,
'attributes.createOn': tx.modifiedOn,
'attributes.createdOn': tx.modifiedOn,
'attributes.content': tx.attributes.message
}
)

View File

@ -105,7 +105,7 @@ export class TDoc extends TObj implements Doc {
@Prop(TypeTimestamp(), core.string.CreatedDate)
@ReadOnly()
createOn!: Timestamp
createdOn!: Timestamp
}
@Model(core.class.AttachedDoc, core.class.Doc)

View File

@ -99,6 +99,9 @@ async function fillCreatedOn (client: MigrationClient): Promise<void> {
) {
continue
}
await client.update<Doc>(domain, { createOn: { $exists: true } }, { $unset: { createOn: 1 } })
while (true) {
try {
const objects = await client.find<Doc>(
@ -115,7 +118,7 @@ async function fillCreatedOn (client: MigrationClient): Promise<void> {
_class: core.class.TxCreateDoc,
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 = (
@ -126,13 +129,13 @@ async function fillCreatedOn (client: MigrationClient): Promise<void> {
'tx._class': core.class.TxCreateDoc,
'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>)
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(
domain,
objects.map((it) => {
@ -140,7 +143,7 @@ async function fillCreatedOn (client: MigrationClient): Promise<void> {
return {
filter: { _id: it._id },
update: {
createdOn: createTx?.createOn ?? it.modifiedOn
createdOn: createTx?.createdOn ?? it.modifiedOn
}
}
})

View File

@ -263,7 +263,7 @@ export function createModel (builder: Builder): void {
orderBy: [
['state', SortingOrder.Ascending],
['modifiedOn', SortingOrder.Descending],
['createOn', SortingOrder.Descending],
['createdOn', SortingOrder.Descending],
['dueDate', SortingOrder.Ascending],
['rank', SortingOrder.Ascending]
],

View File

@ -624,7 +624,7 @@ export function createModel (builder: Builder): void {
orderBy: [
['state', SortingOrder.Ascending],
['modifiedOn', SortingOrder.Descending],
['createOn', SortingOrder.Descending],
['createdOn', SortingOrder.Descending],
['dueDate', SortingOrder.Ascending],
['rank', SortingOrder.Ascending]
],

View File

@ -463,7 +463,7 @@ export function createModel (builder: Builder): void {
['status', SortingOrder.Ascending],
['priority', SortingOrder.Ascending],
['modifiedOn', SortingOrder.Descending],
['createOn', SortingOrder.Descending],
['createdOn', SortingOrder.Descending],
['dueDate', SortingOrder.Ascending],
['rank', SortingOrder.Ascending]
],
@ -592,7 +592,7 @@ export function createModel (builder: Builder): void {
['status', SortingOrder.Ascending],
['priority', SortingOrder.Ascending],
['modifiedOn', SortingOrder.Descending],
['createOn', SortingOrder.Descending],
['createdOn', SortingOrder.Descending],
['dueDate', SortingOrder.Ascending]
],
groupDepth: 1,
@ -1780,7 +1780,7 @@ export function createModel (builder: Builder): void {
orderBy: [
['modifiedOn', SortingOrder.Descending],
['targetDate', SortingOrder.Descending],
['createOn', SortingOrder.Descending]
['createdOn', SortingOrder.Descending]
],
other: [showColors]
}
@ -1852,7 +1852,7 @@ export function createModel (builder: Builder): void {
groupBy: ['lead'],
orderBy: [
['modifiedOn', SortingOrder.Descending],
['createOn', SortingOrder.Descending]
['createdOn', SortingOrder.Descending]
],
other: [showColors]
}

View File

@ -59,13 +59,17 @@ async function migrateViewletPreference (client: MigrationClient): Promise<void>
}
async function migrateSavedFilters (client: MigrationClient): Promise<void> {
await client.move(
DOMAIN_PREFERENCE,
{
_class: view.class.FilteredView
},
DOMAIN_VIEW
)
try {
await client.move(
DOMAIN_PREFERENCE,
{
_class: view.class.FilteredView
},
DOMAIN_VIEW
)
} catch (err: any) {
console.log(err)
}
const preferences = await client.find<FilteredView>(DOMAIN_VIEW, {
_class: view.class.FilteredView,
users: { $exists: false }

View File

@ -57,7 +57,7 @@ export interface Doc extends Obj {
modifiedOn: Timestamp
modifiedBy: Ref<Account>
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.
}
/**

View File

@ -354,7 +354,7 @@ export abstract class TxProcessor implements WithTx {
modifiedBy: tx.modifiedBy,
modifiedOn: tx.modifiedOn,
createdBy: tx.createdBy ?? tx.modifiedBy,
createOn: tx.createOn ?? tx.modifiedOn
createdOn: tx.createdOn ?? tx.modifiedOn
} as T
}

View File

@ -109,7 +109,7 @@
if (docUpdate === undefined || lastView === undefined) return -1
for (let index = 0; index < messages.length; index++) {
const message = messages[index]
if ((message.createOn ?? 0) >= lastView) return index
if ((message.createdOn ?? 0) >= lastView) return index
}
return -1
}
@ -209,8 +209,8 @@
{#if newMessagesPos === i}
<ChannelSeparator title={chunter.string.New} line reverse isNew />
{/if}
{#if i === 0 || isOtherDay(message.createOn ?? 0, messages[i - 1].createOn ?? 0)}
<JumpToDateSelector selectedDate={message.createOn} on:jumpToDate={handleJumpToDate} />
{#if i === 0 || isOtherDay(message.createdOn ?? 0, messages[i - 1].createdOn ?? 0)}
<JumpToDateSelector selectedDate={message.createdOn} on:jumpToDate={handleJumpToDate} />
{/if}
<MessageComponent
isHighlighted={$messageIdForScroll === message._id && $isMessageHighlighted}

View File

@ -228,7 +228,7 @@
{#if employee}
<EmployeePresenter value={employee} shouldShowAvatar={false} inline />
{/if}
<span>{getTime(message.createOn ?? 0)}</span>
<span>{getTime(message.createdOn ?? 0)}</span>
{#if message.editedOn}
<span use:tooltip={{ label: ui.string.TimeTooltip, props: { value: getTime(message.editedOn) } }}>
<Label label={chunter.string.Edited} />

View File

@ -34,7 +34,7 @@
...resultQuery
},
{
sort: { createOn: SortingOrder.Descending },
sort: { createdOn: SortingOrder.Descending },
limit: 100,
lookup: {
_id: { attachments: attachment.class.Attachment },

View File

@ -66,7 +66,7 @@
</div>
</div>
<MessageViewer message={message.content} />
<span class="time">{getTime(message.createOn ?? 0)}</span>
<span class="time">{getTime(message.createdOn ?? 0)}</span>
</div>
{/each}
</div>

View File

@ -70,7 +70,7 @@
const options: FindOptions<ThreadMessage> = {
lookup,
sort: {
createOn: SortingOrder.Descending
createdOn: SortingOrder.Descending
},
total: true
}

View File

@ -164,7 +164,7 @@
if (docUpdate === undefined || lastView === undefined) return -1
for (let index = 0; index < comments.length; index++) {
const comment = comments[index]
if ((comment.createOn ?? 0) >= lastView) return index
if ((comment.createdOn ?? 0) >= lastView) return index
}
return -1
}

View File

@ -37,7 +37,7 @@
},
{
sort: {
createOn: SortingOrder.Descending
createdOn: SortingOrder.Descending
}
}
)

View File

@ -19,7 +19,7 @@
...resultQuery
},
{
sort: { createOn: SortingOrder.Descending },
sort: { createdOn: SortingOrder.Descending },
limit: 100,
lookup: { _id: { statuses: contact.class.Status } }
}

View File

@ -180,7 +180,7 @@
$: resultChannels = mergeChannels(oldChannels, targetChannels, enabledChannels)
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(
(p) => !p[1].hidden && !ignoreKeys.includes(p[0]) && !isCollectionAttr(hierarchy, { key: p[0], attr: p[1] })
)

View File

@ -54,7 +54,9 @@
'tx.attributes.incoming': false
},
(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)
}
)

View File

@ -187,7 +187,7 @@
// Store all extra values.
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)
if (attr === undefined) continue
if (attr.attributeOf === recruit.mixin.Candidate) {

View File

@ -184,7 +184,8 @@ async function ThreadMessageDelete (tx: Tx, control: TriggerControl): Promise<Tx
comment.attachedTo,
{
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
}
)

View File

@ -127,7 +127,7 @@ export async function IsIncomingMessage (
control: TriggerControl
): Promise<boolean> {
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

View File

@ -125,7 +125,7 @@ export async function IsIncomingMessage (
control: TriggerControl
): Promise<boolean> {
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

View File

@ -37,7 +37,7 @@ export class ModifiedMiddleware extends BaseMiddleware implements Middleware {
async tx (ctx: SessionContext, tx: Tx): Promise<TxMiddlewareResult> {
if (tx.modifiedBy !== core.account.System) {
tx.modifiedOn = Date.now()
tx.createOn = tx.createOn ?? tx.modifiedOn
tx.createdOn = tx.createdOn ?? tx.modifiedOn
}
return await this.provideTx(ctx, tx)
}

View File

@ -75,7 +75,7 @@ export const doc1: Task = {
rate: 20,
modifiedBy: 'user' as Ref<Account>,
modifiedOn: 10,
// createOn: 10,
// createdOn: 10,
space: '' as Ref<Space>
}