@@ -131,6 +131,14 @@ func (d *SqlDbConnection) prepareQueryWithDialect(query string, dialect gorp.Dia
131
131
return query
132
132
}
133
133
134
+ func (d * SqlDbConnection ) PrepareDateQueryParam (paramName string ) string {
135
+ if d .dialect == util .DbDriverSQLite {
136
+ return "substr(" + paramName + ", 1, 25)"
137
+ }
138
+
139
+ return paramName
140
+ }
141
+
134
142
func (d * SqlDbConnection ) PrepareQuery (query string ) string {
135
143
return d .prepareQueryWithDialect (query , d .sql .Dialect )
136
144
}
@@ -139,7 +147,7 @@ func formatArgs(args []any) (formattedArgs []any) {
139
147
for _ , arg := range args {
140
148
switch typedArg := arg .(type ) {
141
149
case time.Time :
142
- formattedArgs = append (formattedArgs , typedArg .Format ("2006-01-02 15:04:05.0000000 " ))
150
+ formattedArgs = append (formattedArgs , typedArg .Format ("2006-01-02 15:04:05.000000 " ))
143
151
default :
144
152
formattedArgs = append (formattedArgs , arg )
145
153
}
@@ -893,7 +901,7 @@ func (d *SqlDb) GetTaskStats(projectID int, templateID *int, unit db.TaskStatUni
893
901
Count int `db:"count"`
894
902
}
895
903
896
- q := squirrel .Select ("DATE(SUBSTR( created, 1, 25) ) AS date, status, COUNT(*) AS count" ).
904
+ q := squirrel .Select ("DATE(" + d . connection . PrepareDateQueryParam ( " created" ) + " ) AS date, status, COUNT(*) AS count" ).
897
905
From ("task" ).
898
906
Where ("project_id=?" , projectID ).
899
907
GroupBy ("date, status" ).
@@ -920,7 +928,11 @@ func (d *SqlDb) GetTaskStats(projectID int, templateID *int, unit db.TaskStatUni
920
928
return
921
929
}
922
930
923
- _ , err = d .selectAll (& res , query , args ... )
931
+ _ , err = d .connection .SelectAll (& res , query , args ... )
932
+
933
+ if err != nil {
934
+ return
935
+ }
924
936
925
937
var date string
926
938
var stat * db.TaskStat
0 commit comments