You've already forked DataMate
refactor(data-management): 移除未使用的数据库操作方法并优化查询条件
- 从 DatasetFileMapper 中移除未使用的 update 和 deleteById 方法 - 从 DatasetMapper 中移除未使用的 deleteById 方法 - 在 Python 项目中添加 or_ 操作符导入用于复杂查询 - 为数据集文件查询添加状态过滤条件,排除已归档的文件记录
This commit is contained in:
@@ -26,8 +26,6 @@ public interface DatasetFileMapper extends BaseMapper<DatasetFile> {
|
|||||||
@Param("status") String status,
|
@Param("status") String status,
|
||||||
RowBounds rowBounds);
|
RowBounds rowBounds);
|
||||||
|
|
||||||
int update(DatasetFile file);
|
|
||||||
int deleteById(@Param("id") String id);
|
|
||||||
int updateFilePathPrefix(@Param("datasetId") String datasetId,
|
int updateFilePathPrefix(@Param("datasetId") String datasetId,
|
||||||
@Param("oldPrefix") String oldPrefix,
|
@Param("oldPrefix") String oldPrefix,
|
||||||
@Param("newPrefix") String newPrefix);
|
@Param("newPrefix") String newPrefix);
|
||||||
|
|||||||
@@ -28,6 +28,5 @@ public interface DatasetMapper extends BaseMapper<Dataset> {
|
|||||||
@Param("keyword") String keyword,
|
@Param("keyword") String keyword,
|
||||||
@Param("tagNames") List<String> tagNames);
|
@Param("tagNames") List<String> tagNames);
|
||||||
|
|
||||||
int deleteById(@Param("id") String id);
|
|
||||||
AllDatasetStatisticsResponse getAllDatasetStatistics();
|
AllDatasetStatisticsResponse getAllDatasetStatistics();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,24 +97,6 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<update id="update" parameterType="com.datamate.datamanagement.domain.model.dataset.DatasetFile">
|
|
||||||
UPDATE t_dm_dataset_files
|
|
||||||
SET file_name = #{fileName},
|
|
||||||
file_path = #{filePath},
|
|
||||||
logical_path = #{logicalPath},
|
|
||||||
version = #{version},
|
|
||||||
file_type = #{fileType},
|
|
||||||
file_size = #{fileSize},
|
|
||||||
upload_time = #{uploadTime},
|
|
||||||
last_access_time = #{lastAccessTime},
|
|
||||||
status = #{status}
|
|
||||||
WHERE id = #{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteById" parameterType="string">
|
|
||||||
DELETE FROM t_dm_dataset_files WHERE id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<update id="updateFilePathPrefix">
|
<update id="updateFilePathPrefix">
|
||||||
UPDATE t_dm_dataset_files
|
UPDATE t_dm_dataset_files
|
||||||
SET file_path = CONCAT(#{newPrefix}, SUBSTRING(file_path, LENGTH(#{oldPrefix}) + 1))
|
SET file_path = CONCAT(#{newPrefix}, SUBSTRING(file_path, LENGTH(#{oldPrefix}) + 1))
|
||||||
|
|||||||
@@ -139,10 +139,6 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<delete id="deleteById" parameterType="string">
|
|
||||||
DELETE FROM t_dm_datasets WHERE id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<select id="getAllDatasetStatistics" resultType="com.datamate.datamanagement.interfaces.dto.AllDatasetStatisticsResponse">
|
<select id="getAllDatasetStatistics" resultType="com.datamate.datamanagement.interfaces.dto.AllDatasetStatisticsResponse">
|
||||||
SELECT
|
SELECT
|
||||||
(SELECT COUNT(*) FROM t_dm_datasets) AS total_datasets,
|
(SELECT COUNT(*) FROM t_dm_datasets) AS total_datasets,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import math
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Query, Path
|
from fastapi import APIRouter, Depends, HTTPException, Query, Path
|
||||||
from sqlalchemy import select, update
|
from sqlalchemy import select, update, or_
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.db.session import get_db
|
from app.db.session import get_db
|
||||||
@@ -125,7 +125,10 @@ async def create_mapping(
|
|||||||
)
|
)
|
||||||
|
|
||||||
file_result = await db.execute(
|
file_result = await db.execute(
|
||||||
select(DatasetFiles).where(DatasetFiles.dataset_id == request.dataset_id)
|
select(DatasetFiles).where(
|
||||||
|
DatasetFiles.dataset_id == request.dataset_id,
|
||||||
|
or_(DatasetFiles.status.is_(None), DatasetFiles.status != "ARCHIVED"),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
file_records = file_result.scalars().all()
|
file_records = file_result.scalars().all()
|
||||||
snapshot_file_ids: list[str] = []
|
snapshot_file_ids: list[str] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user