MM-23038: Compliance Report Fixes (#14242)

* add warning count as return value

* add warning count as return value

* fix file name

* update mock

* add setting warning to db

* replace wrongly removed string

* add dummy function to see if it will build

* remove dummy function

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Scott Bishel
2020-05-07 14:12:47 -06:00
коммит произвёл GitHub
родитель bdd0e9febb
Коммит 1031e27fd8
6 изменённых файлов: 35 добавлений и 11 удалений

Просмотреть файл

@@ -5,6 +5,7 @@ package commands
import (
"context"
"fmt"
"os"
"time"
@@ -161,11 +162,15 @@ func buildExportCmdF(format string) func(command *cobra.Command, args []string)
return errors.New("message export feature not available")
}
err2 := a.MessageExport().RunExport(format, startTime)
if err2 != nil {
return err2
warningsCount, appErr := a.MessageExport().RunExport(format, startTime)
if appErr != nil {
return appErr
}
if warningsCount == 0 {
CommandPrettyPrintln("SUCCESS: Your data was exported.")
} else {
CommandPrettyPrintln(fmt.Sprintf("WARNING: %d warnings encountered, see warning.txt for details.", warningsCount))
}
CommandPrettyPrintln("SUCCESS: Your data was exported.")
auditRec := a.MakeAuditRecord("buildExport", audit.Success)
auditRec.AddMeta("format", format)

Просмотреть файл

@@ -11,5 +11,5 @@ import (
type MessageExportInterface interface {
StartSynchronizeJob(ctx context.Context, exportFromTimestamp int64) (*model.Job, *model.AppError)
RunExport(format string, since int64) *model.AppError
RunExport(format string, since int64) (int64, *model.AppError)
}

Просмотреть файл

@@ -18,19 +18,26 @@ type MessageExportInterface struct {
}
// RunExport provides a mock function with given fields: format, since
func (_m *MessageExportInterface) RunExport(format string, since int64) *model.AppError {
func (_m *MessageExportInterface) RunExport(format string, since int64) (int64, *model.AppError) {
ret := _m.Called(format, since)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string, int64) *model.AppError); ok {
var r0 int64
if rf, ok := ret.Get(0).(func(string, int64) int64); ok {
r0 = rf(format, since)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
r0 = ret.Get(0).(int64)
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, int64) *model.AppError); ok {
r1 = rf(format, since)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0
return r0, r1
}
// StartSynchronizeJob provides a mock function with given fields: ctx, exportFromTimestamp

Просмотреть файл

@@ -3870,6 +3870,10 @@
"id": "ent.compliance.csv.post.export.appError",
"translation": "Unable to export a post."
},
{
"id": "ent.compliance.csv.warning.appError",
"translation": "Unable to create the warning file."
},
{
"id": "ent.compliance.csv.zip.creation.appError",
"translation": "Unable to create the zip export file."

Просмотреть файл

@@ -55,6 +55,13 @@ func (srv *JobServer) SetJobProgress(job *model.Job, progress int64) *model.AppE
return nil
}
func (srv *JobServer) SetJobWarning(job *model.Job) *model.AppError {
if _, err := srv.Store.Job().UpdateStatus(job.Id, model.JOB_STATUS_WARNING); err != nil {
return err
}
return nil
}
func (srv *JobServer) SetJobSuccess(job *model.Job) *model.AppError {
if _, err := srv.Store.Job().UpdateStatus(job.Id, model.JOB_STATUS_SUCCESS); err != nil {
return err

Просмотреть файл

@@ -25,6 +25,7 @@ const (
JOB_STATUS_ERROR = "error"
JOB_STATUS_CANCEL_REQUESTED = "cancel_requested"
JOB_STATUS_CANCELED = "canceled"
JOB_STATUS_WARNING = "warning"
)
type Job struct {