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",
|
||||
"prepack": "pnpm build && oclif manifest && oclif readme",
|
||||
"typeorm": "typeorm-ts-node-commonjs",
|
||||
"typeorm:migration-generate": "pnpm typeorm migration:generate -d ./src/utils/typeormDataSource.ts",
|
||||
"watch": "tsc --watch",
|
||||
"version": "oclif readme && git add README.md"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,15 +10,17 @@ export class Assistant implements IAssistant {
|
|||
@Column({ type: 'text' })
|
||||
details: string
|
||||
|
||||
@Column()
|
||||
@Column({ type: 'uuid'})
|
||||
credential: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
iconSrc?: string
|
||||
|
||||
@Column({ type: 'timestamp' })
|
||||
@CreateDateColumn()
|
||||
createdDate: Date
|
||||
|
||||
@Column({ type: 'timestamp' })
|
||||
@UpdateDateColumn()
|
||||
updatedDate: Date
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,11 @@ export class ChatFlow implements IChatFlow {
|
|||
@Column({ nullable: true, type: 'text' })
|
||||
speechToText?: string
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@CreateDateColumn()
|
||||
createdDate: Date
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@UpdateDateColumn()
|
||||
updatedDate: Date
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export class ChatMessage implements IChatMessage {
|
|||
role: MessageType
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
@Column({ type: 'uuid' })
|
||||
chatflowid: string
|
||||
|
||||
@Column({ type: 'text' })
|
||||
|
|
@ -32,15 +32,16 @@ export class ChatMessage implements IChatMessage {
|
|||
@Column()
|
||||
chatType: string
|
||||
|
||||
@Column()
|
||||
@Column({ type: 'uuid' })
|
||||
chatId: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
memoryType?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
@Column({ type: 'uuid', nullable: true })
|
||||
sessionId?: string
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@CreateDateColumn()
|
||||
createdDate: Date
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ export class ChatMessageFeedback implements IChatMessageFeedback {
|
|||
id: string
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
@Column({ type: 'uuid' })
|
||||
chatflowid: string
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
@Column({ type: 'uuid' })
|
||||
chatId: string
|
||||
|
||||
@Column()
|
||||
@Column({ type: 'uuid' })
|
||||
messageId: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
|
|
@ -25,6 +25,7 @@ export class ChatMessageFeedback implements IChatMessageFeedback {
|
|||
@Column({ nullable: true, type: 'text' })
|
||||
content?: string
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@CreateDateColumn()
|
||||
createdDate: Date
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ export class Credential implements ICredential {
|
|||
@Column({ type: 'text' })
|
||||
encryptedData: string
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@CreateDateColumn()
|
||||
createdDate: Date
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@UpdateDateColumn()
|
||||
updatedDate: Date
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,11 @@ export class Tool implements ITool {
|
|||
@Column({ nullable: true, type: 'text' })
|
||||
func?: string
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@CreateDateColumn()
|
||||
createdDate: Date
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@UpdateDateColumn()
|
||||
updatedDate: Date
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ export class Variable implements IVariable {
|
|||
@Column({ default: 'string', type: 'text' })
|
||||
type: string
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@CreateDateColumn()
|
||||
createdDate: Date
|
||||
|
||||
@Column({type:'timestamp'})
|
||||
@UpdateDateColumn()
|
||||
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 { AddSpeechToText1706364937060 } from './1706364937060-AddSpeechToText'
|
||||
import { AddFeedback1707213601923 } from './1707213601923-AddFeedback'
|
||||
import { FieldTypes1710497452584 } from './1710497452584-FieldTypes'
|
||||
|
||||
export const postgresMigrations = [
|
||||
Init1693891895163,
|
||||
|
|
@ -31,5 +32,6 @@ export const postgresMigrations = [
|
|||
AddFileUploadsToChatMessage1701788586491,
|
||||
AddVariableEntity1699325775451,
|
||||
AddSpeechToText1706364937060,
|
||||
AddFeedback1707213601923
|
||||
AddFeedback1707213601923,
|
||||
FieldTypes1710497452584
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1765,6 +1765,12 @@ export class App {
|
|||
return date
|
||||
}
|
||||
|
||||
const aMonthAgo = () => {
|
||||
const date = new Date()
|
||||
date.setMonth(new Date().getMonth() - 1)
|
||||
return date
|
||||
}
|
||||
|
||||
let fromDate
|
||||
if (startDate) fromDate = setDateToStartOrEndOfDay(startDate, 'start')
|
||||
|
||||
|
|
@ -1795,7 +1801,7 @@ export class App {
|
|||
|
||||
// set date range
|
||||
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()
|
||||
})
|
||||
// sort
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
import { DataSource } from 'typeorm'
|
||||
import { getDataSource } from '../DataSource'
|
||||
|
||||
export const dataSource: DataSource = getDataSource()
|
||||
Loading…
Reference in New Issue