优化待确认作品查询SQL,调整状态过滤条件位置
This commit is contained in:
parent
24a6fd1eba
commit
150e7162fe
@ -274,19 +274,19 @@ func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (data []model.CastWor
|
|||||||
subQuery := app.ModuleClients.BundleDB.
|
subQuery := app.ModuleClients.BundleDB.
|
||||||
Table("cast_work_log").
|
Table("cast_work_log").
|
||||||
Select("work_uuid, MAX(update_time) AS max_update_time").
|
Select("work_uuid, MAX(update_time) AS max_update_time").
|
||||||
Group("work_uuid")
|
Group("work_uuid").Where("work_status in ?", []int{4, 5, 6, 7})
|
||||||
|
|
||||||
err = app.ModuleClients.BundleDB.
|
err = app.ModuleClients.BundleDB.
|
||||||
Table("cast_work_log AS cwl").
|
Table("cast_work_log AS cwl").
|
||||||
Joins("INNER JOIN (?) AS t ON cwl.work_uuid = t.work_uuid AND cwl.update_time = t.max_update_time", subQuery).
|
Joins("INNER JOIN (?) AS t ON cwl.work_uuid = t.work_uuid AND cwl.update_time = t.max_update_time", subQuery).
|
||||||
Where("artist_uuid = ?", req.ArtistUuid).Where("confirmed_at = ?", 0).Where("work_status in ?", []int{4, 5, 6, 7}).Count(&unconfirmed).Error
|
Where("artist_uuid = ?", req.ArtistUuid).Where("confirmed_at = ?", 0).Count(&unconfirmed).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
session := app.ModuleClients.BundleDB.
|
session := app.ModuleClients.BundleDB.
|
||||||
Table("cast_work_log AS cwl").
|
Table("cast_work_log AS cwl").
|
||||||
Joins("INNER JOIN (?) AS t ON cwl.work_uuid = t.work_uuid AND cwl.update_time = t.max_update_time", subQuery).
|
Joins("INNER JOIN (?) AS t ON cwl.work_uuid = t.work_uuid AND cwl.update_time = t.max_update_time", subQuery).
|
||||||
Where("artist_uuid = ?", req.ArtistUuid).Where("work_status in ?", []int{4, 5, 6, 7})
|
Where("artist_uuid = ?", req.ArtistUuid)
|
||||||
err = session.Count(&total).Error
|
err = session.Count(&total).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user