mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-12 02:19:55 +08:00
add the view of chatStartupLog
This commit is contained in:
63
packages/sqlite-plugin/src/entity/VChatStartupLog.ts
Normal file
63
packages/sqlite-plugin/src/entity/VChatStartupLog.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { requireTypeorm } from "../utils/module-loader";
|
||||
const { ViewEntity, ViewColumn } = requireTypeorm();
|
||||
@ViewEntity({
|
||||
expression: `SELECT
|
||||
job_info.*,
|
||||
user_info.name as userName,
|
||||
chat_startup_log.date,
|
||||
boss_info.name AS bossName,
|
||||
company_info.name AS companyName
|
||||
FROM
|
||||
chat_startup_log
|
||||
LEFT JOIN job_info ON chat_startup_log.encryptJobId = job_info.encryptJobId
|
||||
LEFT JOIN user_info ON chat_startup_log.encryptCurrentUserId = user_info.encryptUserId
|
||||
LEFT JOIN boss_info ON boss_info.encryptBossId = job_info.encryptBossId
|
||||
LEFT JOIN company_info ON company_info.encryptCompanyId = job_info.encryptCompanyId
|
||||
`,
|
||||
})
|
||||
export class VChatStartupLog {
|
||||
@ViewColumn()
|
||||
encryptJobId: number;
|
||||
|
||||
@ViewColumn()
|
||||
jobName: string;
|
||||
|
||||
@ViewColumn()
|
||||
positionName: string;
|
||||
|
||||
@ViewColumn()
|
||||
salaryLow: number | null;
|
||||
|
||||
@ViewColumn()
|
||||
salaryHeigh: number | null;
|
||||
|
||||
@ViewColumn()
|
||||
salaryMonth: number | null;
|
||||
|
||||
@ViewColumn()
|
||||
experienceName: number | null;
|
||||
|
||||
@ViewColumn()
|
||||
publishDate: Date | null;
|
||||
|
||||
@ViewColumn()
|
||||
degreeName: string;
|
||||
|
||||
@ViewColumn()
|
||||
address: string;
|
||||
|
||||
@ViewColumn()
|
||||
description: string;
|
||||
|
||||
@ViewColumn()
|
||||
userName: string;
|
||||
|
||||
@ViewColumn()
|
||||
date: string;
|
||||
|
||||
@ViewColumn()
|
||||
bossName: string;
|
||||
|
||||
@ViewColumn()
|
||||
companyName: string;
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { JobInfo } from "./entity/JobInfo";
|
||||
import { JobInfoChangeLog } from "./entity/JobInfoChangeLog";
|
||||
import { BossActiveStatusRecord } from "./entity/BossActiveStatusRecord";
|
||||
import { UserInfo } from "./entity/UserInfo";
|
||||
import { VChatStartupLog } from "./entity/VChatStartupLog";
|
||||
|
||||
import sqlite3 from 'sqlite3';
|
||||
import * as cliHighlight from 'cli-highlight';
|
||||
@@ -36,6 +37,7 @@ export function initDb(dbFilePath) {
|
||||
JobInfoChangeLog,
|
||||
BossActiveStatusRecord,
|
||||
UserInfo,
|
||||
VChatStartupLog
|
||||
],
|
||||
});
|
||||
return appDataSource.initialize();
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import 'reflect-metadata'
|
||||
import { parentPort } from 'node:worker_threads'
|
||||
import { initDb } from '@geekgeekrun/sqlite-plugin'
|
||||
import typeorm from 'typeorm'
|
||||
import { type DataSource } from 'typeorm'
|
||||
import { getPublicDbFilePath } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
import { VChatStartupLog } from '@geekgeekrun/sqlite-plugin/dist/entity/VChatStartupLog'
|
||||
import { measureExecutionTime } from '../../../../../../common/utils/performance'
|
||||
|
||||
const dbInitPromise = initDb(getPublicDbFilePath())
|
||||
let dataSource = null
|
||||
let dataSource: DataSource | null = null
|
||||
|
||||
dbInitPromise.then(
|
||||
(_dataSource) => {
|
||||
@@ -26,21 +28,26 @@ dbInitPromise.then(
|
||||
|
||||
const payloadHandler = {
|
||||
async getAutoStartChatRecord(payload) {
|
||||
return {
|
||||
x: 'zzzz',
|
||||
...payload
|
||||
}
|
||||
const result = await measureExecutionTime(
|
||||
dataSource!
|
||||
.createQueryBuilder()
|
||||
.select('*')
|
||||
.from(VChatStartupLog, 'vChatStartupLog')
|
||||
.getRawMany()
|
||||
)
|
||||
console.log(result)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
async function attachMessageHandler() {
|
||||
if (!dataSource) {
|
||||
await dbInitPromise
|
||||
}
|
||||
parentPort?.on('message', async (event) => {
|
||||
const { _uuid, ...restObj } = event
|
||||
const { type } = event
|
||||
|
||||
if (!dataSource) {
|
||||
await dbInitPromise
|
||||
}
|
||||
const result = await payloadHandler[type](restObj)
|
||||
parentPort?.postMessage({
|
||||
_uuid,
|
||||
|
||||
Reference in New Issue
Block a user