Skip to content

Commit

Permalink
fix(sidepanel): data upload record total for statistic task, file upl…
Browse files Browse the repository at this point in the history
…oad failure return error message for data upload task
  • Loading branch information
lastsunday committed Nov 19, 2024
1 parent 6ce04fc commit 5524162
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

## WIP

### 🐛 Fixed

1. (Sidepanel)修复记录上传记录数查询。

### ✏️ Changed

1. (Sidepanel)修复公司数据增量上传逻辑。
2. (Sidepanel)为数据文件增加数据结构版本号。
1. (Sidepanel)修改公司数据增量上传逻辑。
2. (Sidepanel)修改数据上传错误处理逻辑。
3. (Sidepanel)为数据文件增加数据结构版本号。

## 1.30.2(2024-11-18)

Expand Down
6 changes: 3 additions & 3 deletions src/background/service/taskService.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,12 @@ async function uploadData({ userName, repoName, dirPath, dataTypeName, dataList,
let zipData = await zipFileToBase64(dataTypeName, excelData);
let filePath = `${dirPath}/${dataTypeName}.zip`;
try {
let result = await GithubApi.createFileContent(userName, repoName, filePath, zipData, "upload job data", { getTokenFunction: getToken, setTokenFunction: setToken, });
await GithubApi.createFileContent(userName, repoName, filePath, zipData, "upload job data", { getTokenFunction: getToken, setTokenFunction: setToken, });
infoLog(`[Task Data Upload ${dataTypeName}] create file ${filePath} success`);
return result;
} catch (e) {
if (e == EXCEPTION.CREATION_FAILED) {
infoLog(`[Task Data Upload ${dataTypeName}] create file ${filePath} failure`);
return `upload file ${filePath} failure`;
} else {
throw e;
}
Expand Down Expand Up @@ -607,7 +607,7 @@ async function uploadDataByDataId(dataId, dataTypeName, getDataFunction, jsonObj
let endDatetime = taskDataUpload.endDatetime;
let dirPath = getPathByDatetime({ endDatetime });
await createRepoIfNotExists({ userName, repoName });
await uploadData({
return await uploadData({
userName, repoName, dirPath,
dataTypeName,
dataList: (await getDataFunction({ startDatetime, endDatetime })).items,
Expand Down
14 changes: 7 additions & 7 deletions src/offscreen/service/taskService.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,17 @@ export const TaskService = {
let endDatetime = dateToStr(param.endDatetime);

//upload total
const uploadTotalSql = `SELECT SUM(data_count) AS count FROM task_data_upload ${genUpdatetimeCondition(startDatetime, endDatetime)}`;
const uploadTotalSql = `SELECT SUM(t2.data_count) AS count FROM task AS t1 LEFT JOIN task_data_upload AS t2 ON t1.data_id = t2.id ${genUpdatetimeCondition({ updateDatetimeColumn: "t1.update_datetime", startDatetime, endDatetime, otherConditionSql: ` AND t1.status = 'FINISHED' AND t1.type IN ('JOB_DATA_UPLOAD','COMPANY_DATA_UPLOAD','COMPANY_TAG_DATA_UPLOAD')` })}`;
let uploadRecordTotalCount = [];
(await getDb()).exec({
sql: uploadTotalSql,
rowMode: "object",
resultRows: uploadRecordTotalCount,
});
result.uploadRecordTotalCount = uploadRecordTotalCount[0].count;

//download total
const downloadTotalSql = `SELECT COUNT(*) AS count FROM task ${genUpdatetimeCondition(startDatetime, endDatetime, ` AND status = 'FINISHED' AND type IN ('JOB_DATA_DOWNLOAD','COMPANY_DATA_DOWNLOAD','COMPANY_TAG_DATA_DOWNLOAD')`)} `;
const downloadTotalSql = `SELECT COUNT(*) AS count FROM task ${genUpdatetimeCondition({ startDatetime, endDatetime, otherConditionSql: ` AND status = 'FINISHED' AND type IN ('JOB_DATA_DOWNLOAD','COMPANY_DATA_DOWNLOAD','COMPANY_TAG_DATA_DOWNLOAD')` })} `;
let downloadFileTotalCount = [];
(await getDb()).exec({
sql: downloadTotalSql,
Expand All @@ -212,7 +212,7 @@ export const TaskService = {
result.downloadFileTotalCount = downloadFileTotalCount[0].count;

//merge total
const mergeTotalSql = `SELECT SUM(data_count) AS count FROM task_data_merge ${genUpdatetimeCondition(startDatetime, endDatetime)}`;
const mergeTotalSql = `SELECT SUM(data_count) AS count FROM task_data_merge ${genUpdatetimeCondition({ startDatetime, endDatetime })}`;
let mergeRecordTotalCount = [];
(await getDb()).exec({
sql: mergeTotalSql,
Expand All @@ -231,17 +231,17 @@ export const TaskService = {
},
};

function genUpdatetimeCondition(startDatetime, endDatetime, otherConditionSql) {
function genUpdatetimeCondition({ startDatetime, endDatetime, otherConditionSql, updateDatetimeColumn }) {
let whereCondition = "";
if (startDatetime) {
whereCondition +=
" AND update_datetime >= '" +
` AND ${updateDatetimeColumn ?? "update_datetime"} >= '` +
dayjs(startDatetime).format("YYYY-MM-DD HH:mm:ss") +
"'";
}
if (endDatetime) {
whereCondition +=
" AND update_datetime < '" +
` AND ${updateDatetimeColumn ?? "update_datetime"} < '` +
dayjs(endDatetime).format("YYYY-MM-DD HH:mm:ss") +
"'";
}
Expand Down

0 comments on commit 5524162

Please sign in to comment.