feat(config): 添加写入G4和G5数据库的开关控制
新增环境变量和配置项用于控制是否写入G4和G5的action和status数据
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -90,5 +90,9 @@ export const config = {
|
||||
schema: process.env.ROOM_STATUS_DB_SCHEMA_G5 || 'room_status',
|
||||
table: process.env.ROOM_STATUS_DB_TABLE_G5 || 'room_status_moment_g5'
|
||||
},
|
||||
enableLoopNameAutoGeneration: process.env.ENABLE_LOOP_NAME_AUTO_GENERATION === 'true'
|
||||
enableLoopNameAutoGeneration: process.env.ENABLE_LOOP_NAME_AUTO_GENERATION === 'true',
|
||||
writeToG4Action: process.env.WRITE_TO_G4_ACTION !== 'false',
|
||||
writeToG4Status: process.env.WRITE_TO_G4_STATUS !== 'false',
|
||||
writeToG5Action: process.env.WRITE_TO_G5_ACTION !== 'false',
|
||||
writeToG5Status: process.env.WRITE_TO_G5_STATUS !== 'false'
|
||||
};
|
||||
|
||||
@@ -102,10 +102,10 @@ const bootstrap = async () => {
|
||||
try {
|
||||
const statusUpdate = extractStatusUpdate(payload);
|
||||
if (statusUpdate) {
|
||||
if (config.roomStatusDb.enabled) {
|
||||
if (config.roomStatusDb.enabled && config.writeToG4Status) {
|
||||
statusBatchProcessorG4.add(statusUpdate);
|
||||
}
|
||||
if (statusBatchProcessorG5 && config.roomStatusDbG5.enabled) {
|
||||
if (statusBatchProcessorG5 && config.roomStatusDbG5.enabled && config.writeToG5Status) {
|
||||
statusBatchProcessorG5.add(statusUpdate);
|
||||
}
|
||||
}
|
||||
@@ -115,10 +115,10 @@ const bootstrap = async () => {
|
||||
|
||||
let inserted = 0;
|
||||
const dbActions = [];
|
||||
if (config.db.enabled) {
|
||||
if (config.db.enabled && config.writeToG4Action) {
|
||||
dbActions.push(batchProcessorG4.add({ rows }).then(c => { inserted = Math.max(inserted, c); }));
|
||||
}
|
||||
if (batchProcessorG5 && config.dbG5.enabled) {
|
||||
if (batchProcessorG5 && config.dbG5.enabled && config.writeToG5Action) {
|
||||
dbActions.push(batchProcessorG5.add({ rows }).then(c => { inserted = Math.max(inserted, c); }));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user