mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-05 23:47:54 +08:00
add the view of chatStartupLog
This commit is contained in:
@@ -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 { JobInfoChangeLog } from "./entity/JobInfoChangeLog";
|
||||||
import { BossActiveStatusRecord } from "./entity/BossActiveStatusRecord";
|
import { BossActiveStatusRecord } from "./entity/BossActiveStatusRecord";
|
||||||
import { UserInfo } from "./entity/UserInfo";
|
import { UserInfo } from "./entity/UserInfo";
|
||||||
|
import { VChatStartupLog } from "./entity/VChatStartupLog";
|
||||||
|
|
||||||
import sqlite3 from 'sqlite3';
|
import sqlite3 from 'sqlite3';
|
||||||
import * as cliHighlight from 'cli-highlight';
|
import * as cliHighlight from 'cli-highlight';
|
||||||
@@ -36,6 +37,7 @@ export function initDb(dbFilePath) {
|
|||||||
JobInfoChangeLog,
|
JobInfoChangeLog,
|
||||||
BossActiveStatusRecord,
|
BossActiveStatusRecord,
|
||||||
UserInfo,
|
UserInfo,
|
||||||
|
VChatStartupLog
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
return appDataSource.initialize();
|
return appDataSource.initialize();
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
|
import 'reflect-metadata'
|
||||||
import { parentPort } from 'node:worker_threads'
|
import { parentPort } from 'node:worker_threads'
|
||||||
import { initDb } from '@geekgeekrun/sqlite-plugin'
|
import { initDb } from '@geekgeekrun/sqlite-plugin'
|
||||||
import typeorm from 'typeorm'
|
|
||||||
import { type DataSource } from 'typeorm'
|
import { type DataSource } from 'typeorm'
|
||||||
import { getPublicDbFilePath } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
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())
|
const dbInitPromise = initDb(getPublicDbFilePath())
|
||||||
let dataSource = null
|
let dataSource: DataSource | null = null
|
||||||
|
|
||||||
dbInitPromise.then(
|
dbInitPromise.then(
|
||||||
(_dataSource) => {
|
(_dataSource) => {
|
||||||
@@ -26,21 +28,26 @@ dbInitPromise.then(
|
|||||||
|
|
||||||
const payloadHandler = {
|
const payloadHandler = {
|
||||||
async getAutoStartChatRecord(payload) {
|
async getAutoStartChatRecord(payload) {
|
||||||
return {
|
const result = await measureExecutionTime(
|
||||||
x: 'zzzz',
|
dataSource!
|
||||||
...payload
|
.createQueryBuilder()
|
||||||
}
|
.select('*')
|
||||||
|
.from(VChatStartupLog, 'vChatStartupLog')
|
||||||
|
.getRawMany()
|
||||||
|
)
|
||||||
|
console.log(result)
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function attachMessageHandler() {
|
async function attachMessageHandler() {
|
||||||
if (!dataSource) {
|
|
||||||
await dbInitPromise
|
|
||||||
}
|
|
||||||
parentPort?.on('message', async (event) => {
|
parentPort?.on('message', async (event) => {
|
||||||
const { _uuid, ...restObj } = event
|
const { _uuid, ...restObj } = event
|
||||||
const { type } = event
|
const { type } = event
|
||||||
|
|
||||||
|
if (!dataSource) {
|
||||||
|
await dbInitPromise
|
||||||
|
}
|
||||||
const result = await payloadHandler[type](restObj)
|
const result = await payloadHandler[type](restObj)
|
||||||
parentPort?.postMessage({
|
parentPort?.postMessage({
|
||||||
_uuid,
|
_uuid,
|
||||||
|
|||||||
Reference in New Issue
Block a user