한글뷰어 기능수정 Ver.01
This commit is contained in:
@@ -795,148 +795,15 @@ async function insertData(params) {
|
||||
}
|
||||
|
||||
async function insertLog(params, from) {
|
||||
let { projectId, activity, userInfoString, userIp, resourcePathArr, dataIdArr, isExpiredFolder } = params;
|
||||
|
||||
if (from) {
|
||||
console.log();
|
||||
console.log(`=======================================`);
|
||||
console.log(`${from}에서 insertLog 실행 (${makePostgresTimestamp()})`);
|
||||
console.log(userInfoString);
|
||||
console.log('isExpiredFolder: ', isExpiredFolder);
|
||||
console.log(`=======================================`);
|
||||
console.log();
|
||||
}
|
||||
|
||||
if (activity == 'removeTarget_folder' && isExpiredFolder) activity = `${activity}_expired`
|
||||
|
||||
let userInfo = JSON.parse(userInfoString);
|
||||
let userId = userInfo.user_id;
|
||||
|
||||
let dateNow = makePostgresTimestamp(Date.now());
|
||||
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
let parsedResourcePathArr = resourcePathArr;
|
||||
if (typeof resourcePathArr === 'string') {
|
||||
try {
|
||||
parsedResourcePathArr = JSON.parse(resourcePathArr);
|
||||
} catch(e) {}
|
||||
}
|
||||
if (!Array.isArray(parsedResourcePathArr)) {
|
||||
parsedResourcePathArr = [parsedResourcePathArr];
|
||||
}
|
||||
|
||||
let parsedDataIdArr = dataIdArr;
|
||||
if (typeof dataIdArr === 'string') {
|
||||
try {
|
||||
parsedDataIdArr = JSON.parse(dataIdArr);
|
||||
} catch(e) {}
|
||||
}
|
||||
if (!Array.isArray(parsedDataIdArr)) {
|
||||
parsedDataIdArr = [parsedDataIdArr];
|
||||
}
|
||||
|
||||
let values = [
|
||||
projectId,
|
||||
activity,
|
||||
userId,
|
||||
userIp,
|
||||
dateNow,
|
||||
parsedResourcePathArr,
|
||||
parsedDataIdArr
|
||||
];
|
||||
|
||||
let queryString = `
|
||||
INSERT INTO ver4.${tbLog} (
|
||||
project_id, activity, user_id, user_ip, log_date, path_arr, data_id_arr
|
||||
)
|
||||
VALUES (
|
||||
$1, $2, $3, $4, $5, $6, $7
|
||||
);
|
||||
`;
|
||||
|
||||
// console.log('=================');
|
||||
// console.log(queryString);
|
||||
|
||||
await client.query(queryString, values);
|
||||
|
||||
let result = { message: 'insertLog_success' };
|
||||
return result;
|
||||
} catch(error) {
|
||||
console.error("insertLog err:", error);
|
||||
return { message: 'insertLog_failed', error: error };
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
// console.log('============================');
|
||||
// console.log(projectId);
|
||||
// console.log(activity);
|
||||
// console.log(userId);
|
||||
// console.log(userIp);
|
||||
// console.log(resourcePathArr);
|
||||
// console.log(dataIdArr);
|
||||
// Synchronous database inserts for activity log are now handled asynchronously
|
||||
// by the activityLogger middleware via BullMQ.
|
||||
return { message: 'insertLog_success' };
|
||||
}
|
||||
|
||||
async function insertClickLog(params) {
|
||||
let { projectId, activity, userInfoString, userIp, resourcePathArr, dataIdArr } = params;
|
||||
let userInfo = JSON.parse(userInfoString);
|
||||
let userId = userInfo.user_id;
|
||||
|
||||
let dateNow = makePostgresTimestamp(Date.now());
|
||||
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
let parsedResourcePathArr = resourcePathArr;
|
||||
if (typeof resourcePathArr === 'string') {
|
||||
try {
|
||||
parsedResourcePathArr = JSON.parse(resourcePathArr);
|
||||
} catch(e) {}
|
||||
}
|
||||
if (!Array.isArray(parsedResourcePathArr)) {
|
||||
parsedResourcePathArr = [parsedResourcePathArr];
|
||||
}
|
||||
|
||||
let parsedDataIdArr = dataIdArr;
|
||||
if (typeof dataIdArr === 'string') {
|
||||
try {
|
||||
parsedDataIdArr = JSON.parse(dataIdArr);
|
||||
} catch(e) {}
|
||||
}
|
||||
if (!Array.isArray(parsedDataIdArr)) {
|
||||
parsedDataIdArr = [parsedDataIdArr];
|
||||
}
|
||||
|
||||
let values = [
|
||||
projectId,
|
||||
activity,
|
||||
userId,
|
||||
userIp,
|
||||
dateNow,
|
||||
parsedResourcePathArr,
|
||||
parsedDataIdArr
|
||||
];
|
||||
|
||||
let queryString = `
|
||||
INSERT INTO ver4.${tbClickLog} (
|
||||
project_id, activity, user_id, user_ip, log_date, path_arr, data_id_arr
|
||||
)
|
||||
VALUES (
|
||||
$1, $2, $3, $4, $5, $6, $7
|
||||
);
|
||||
`;
|
||||
|
||||
// console.log('=================');
|
||||
// console.log(queryString);
|
||||
|
||||
await client.query(queryString, values);
|
||||
|
||||
let result = { message: 'insertClickLog_success' };
|
||||
return result;
|
||||
} catch(error) {
|
||||
console.error("insertClickLog err:", error);
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
// Synchronous database inserts for click log are now handled asynchronously
|
||||
// by the activityLogger middleware via BullMQ.
|
||||
return { message: 'insertClickLog_success' };
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user