Fix#1947 (#1960)
* Fixes #1947 * Lint fix * fallback from timestamp with timezone to timestamp --------- Co-authored-by: Emrah TOY <emrah.toy@mtekbilisim.com>
This commit is contained in:
parent
ac02cde2fa
commit
ec1bbc84bc
|
|
@ -33,6 +33,7 @@
|
||||||
"postpack": "shx rm -f oclif.manifest.json",
|
"postpack": "shx rm -f oclif.manifest.json",
|
||||||
"prepack": "pnpm build && oclif manifest && oclif readme",
|
"prepack": "pnpm build && oclif manifest && oclif readme",
|
||||||
"typeorm": "typeorm-ts-node-commonjs",
|
"typeorm": "typeorm-ts-node-commonjs",
|
||||||
|
"typeorm:migration-generate": "pnpm typeorm migration:generate -d ./src/utils/typeormDataSource.ts",
|
||||||
"watch": "tsc --watch",
|
"watch": "tsc --watch",
|
||||||
"version": "oclif readme && git add README.md"
|
"version": "oclif readme && git add README.md"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,15 +10,17 @@ export class Assistant implements IAssistant {
|
||||||
@Column({ type: 'text' })
|
@Column({ type: 'text' })
|
||||||
details: string
|
details: string
|
||||||
|
|
||||||
@Column()
|
@Column({ type: 'uuid'})
|
||||||
credential: string
|
credential: string
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
iconSrc?: string
|
iconSrc?: string
|
||||||
|
|
||||||
|
@Column({ type: 'timestamp' })
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdDate: Date
|
createdDate: Date
|
||||||
|
|
||||||
|
@Column({ type: 'timestamp' })
|
||||||
@UpdateDateColumn()
|
@UpdateDateColumn()
|
||||||
updatedDate: Date
|
updatedDate: Date
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,11 @@ export class ChatFlow implements IChatFlow {
|
||||||
@Column({ nullable: true, type: 'text' })
|
@Column({ nullable: true, type: 'text' })
|
||||||
speechToText?: string
|
speechToText?: string
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdDate: Date
|
createdDate: Date
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@UpdateDateColumn()
|
@UpdateDateColumn()
|
||||||
updatedDate: Date
|
updatedDate: Date
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export class ChatMessage implements IChatMessage {
|
||||||
role: MessageType
|
role: MessageType
|
||||||
|
|
||||||
@Index()
|
@Index()
|
||||||
@Column()
|
@Column({ type: 'uuid' })
|
||||||
chatflowid: string
|
chatflowid: string
|
||||||
|
|
||||||
@Column({ type: 'text' })
|
@Column({ type: 'text' })
|
||||||
|
|
@ -32,15 +32,16 @@ export class ChatMessage implements IChatMessage {
|
||||||
@Column()
|
@Column()
|
||||||
chatType: string
|
chatType: string
|
||||||
|
|
||||||
@Column()
|
@Column({ type: 'uuid' })
|
||||||
chatId: string
|
chatId: string
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
memoryType?: string
|
memoryType?: string
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ type: 'uuid', nullable: true })
|
||||||
sessionId?: string
|
sessionId?: string
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdDate: Date
|
createdDate: Date
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,14 @@ export class ChatMessageFeedback implements IChatMessageFeedback {
|
||||||
id: string
|
id: string
|
||||||
|
|
||||||
@Index()
|
@Index()
|
||||||
@Column()
|
@Column({ type: 'uuid' })
|
||||||
chatflowid: string
|
chatflowid: string
|
||||||
|
|
||||||
@Index()
|
@Index()
|
||||||
@Column()
|
@Column({ type: 'uuid' })
|
||||||
chatId: string
|
chatId: string
|
||||||
|
|
||||||
@Column()
|
@Column({ type: 'uuid' })
|
||||||
messageId: string
|
messageId: string
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
|
|
@ -25,6 +25,7 @@ export class ChatMessageFeedback implements IChatMessageFeedback {
|
||||||
@Column({ nullable: true, type: 'text' })
|
@Column({ nullable: true, type: 'text' })
|
||||||
content?: string
|
content?: string
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdDate: Date
|
createdDate: Date
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,11 @@ export class Credential implements ICredential {
|
||||||
@Column({ type: 'text' })
|
@Column({ type: 'text' })
|
||||||
encryptedData: string
|
encryptedData: string
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdDate: Date
|
createdDate: Date
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@UpdateDateColumn()
|
@UpdateDateColumn()
|
||||||
updatedDate: Date
|
updatedDate: Date
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,11 @@ export class Tool implements ITool {
|
||||||
@Column({ nullable: true, type: 'text' })
|
@Column({ nullable: true, type: 'text' })
|
||||||
func?: string
|
func?: string
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdDate: Date
|
createdDate: Date
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@UpdateDateColumn()
|
@UpdateDateColumn()
|
||||||
updatedDate: Date
|
updatedDate: Date
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,11 @@ export class Variable implements IVariable {
|
||||||
@Column({ default: 'string', type: 'text' })
|
@Column({ default: 'string', type: 'text' })
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdDate: Date
|
createdDate: Date
|
||||||
|
|
||||||
|
@Column({type:'timestamp'})
|
||||||
@UpdateDateColumn()
|
@UpdateDateColumn()
|
||||||
updatedDate: Date
|
updatedDate: Date
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm'
|
||||||
|
|
||||||
|
export class FieldTypes1710497452584 implements MigrationInterface {
|
||||||
|
name = 'FieldTypes1710497452584'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message" ALTER COLUMN "chatflowid" type uuid USING "chatflowid"::uuid`)
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message" ALTER COLUMN "chatId" type uuid USING "chatId"::uuid`)
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message" ALTER COLUMN "sessionId" type uuid USING "sessionId"::uuid`)
|
||||||
|
|
||||||
|
await queryRunner.query(`ALTER TABLE "assistant" ALTER COLUMN "credential" type uuid USING "credential"::uuid`)
|
||||||
|
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message_feedback" ALTER COLUMN "chatflowid" type uuid USING "chatflowid"::uuid`)
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message_feedback" ALTER COLUMN "chatId" type uuid USING "chatId"::uuid`)
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message_feedback" ALTER COLUMN "messageId" type uuid USING "messageId"::uuid`)
|
||||||
|
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message_feedback" ADD CONSTRAINT "UQ_6352078b5a294f2d22179ea7955" UNIQUE ("messageId")`)
|
||||||
|
|
||||||
|
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_f56c36fe42894d57e5c664d229" ON "chat_message" ("chatflowid") `)
|
||||||
|
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_f56c36fe42894d57e5c664d230" ON "chat_message_feedback" ("chatflowid") `)
|
||||||
|
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_9acddcb7a2b51fe37669049fc6" ON "chat_message_feedback" ("chatId") `)
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_9acddcb7a2b51fe37669049fc6"`)
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_f56c36fe42894d57e5c664d229"`)
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_f56c36fe42894d57e5c664d230"`)
|
||||||
|
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message_feedback" DROP CONSTRAINT "UQ_6352078b5a294f2d22179ea7955"`)
|
||||||
|
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message" ALTER COLUMN "chatflowid" type varchar USING "chatflowid"::varchar`)
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message" ALTER COLUMN "chatId" type varchar USING "chatId"::varchar`)
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message" ALTER COLUMN "sessionId" type varchar USING "sessionId"::varchar`)
|
||||||
|
|
||||||
|
await queryRunner.query(`ALTER TABLE "assistant" ALTER COLUMN "credential" type varchar USING "credential"::varchar`)
|
||||||
|
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message_feedback" ALTER COLUMN "chatflowid" type varchar USING "chatflowid"::varchar`)
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message_feedback" ALTER COLUMN "chatId" type varchar USING "chatId"::varchar`)
|
||||||
|
await queryRunner.query(`ALTER TABLE "chat_message_feedback" ALTER COLUMN "messageId" type varchar USING "messageId"::varchar`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,7 @@ import { AddFileUploadsToChatMessage1701788586491 } from './1701788586491-AddFil
|
||||||
import { AddVariableEntity1699325775451 } from './1702200925471-AddVariableEntity'
|
import { AddVariableEntity1699325775451 } from './1702200925471-AddVariableEntity'
|
||||||
import { AddSpeechToText1706364937060 } from './1706364937060-AddSpeechToText'
|
import { AddSpeechToText1706364937060 } from './1706364937060-AddSpeechToText'
|
||||||
import { AddFeedback1707213601923 } from './1707213601923-AddFeedback'
|
import { AddFeedback1707213601923 } from './1707213601923-AddFeedback'
|
||||||
|
import { FieldTypes1710497452584 } from './1710497452584-FieldTypes'
|
||||||
|
|
||||||
export const postgresMigrations = [
|
export const postgresMigrations = [
|
||||||
Init1693891895163,
|
Init1693891895163,
|
||||||
|
|
@ -31,5 +32,6 @@ export const postgresMigrations = [
|
||||||
AddFileUploadsToChatMessage1701788586491,
|
AddFileUploadsToChatMessage1701788586491,
|
||||||
AddVariableEntity1699325775451,
|
AddVariableEntity1699325775451,
|
||||||
AddSpeechToText1706364937060,
|
AddSpeechToText1706364937060,
|
||||||
AddFeedback1707213601923
|
AddFeedback1707213601923,
|
||||||
|
FieldTypes1710497452584
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1765,6 +1765,12 @@ export class App {
|
||||||
return date
|
return date
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const aMonthAgo = () => {
|
||||||
|
const date = new Date()
|
||||||
|
date.setMonth(new Date().getMonth() - 1)
|
||||||
|
return date
|
||||||
|
}
|
||||||
|
|
||||||
let fromDate
|
let fromDate
|
||||||
if (startDate) fromDate = setDateToStartOrEndOfDay(startDate, 'start')
|
if (startDate) fromDate = setDateToStartOrEndOfDay(startDate, 'start')
|
||||||
|
|
||||||
|
|
@ -1795,7 +1801,7 @@ export class App {
|
||||||
|
|
||||||
// set date range
|
// set date range
|
||||||
query.andWhere('chat_message.createdDate BETWEEN :fromDate AND :toDate', {
|
query.andWhere('chat_message.createdDate BETWEEN :fromDate AND :toDate', {
|
||||||
fromDate: fromDate ?? new Date().setMonth(new Date().getMonth() - 1),
|
fromDate: fromDate ?? aMonthAgo(),
|
||||||
toDate: toDate ?? new Date()
|
toDate: toDate ?? new Date()
|
||||||
})
|
})
|
||||||
// sort
|
// sort
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
import { DataSource } from 'typeorm'
|
||||||
|
import { getDataSource } from '../DataSource'
|
||||||
|
|
||||||
|
export const dataSource: DataSource = getDataSource()
|
||||||
Loading…
Reference in New Issue