Mercurial > gemma
comparison pkg/imports/report.go @ 5601:1222b777f51f
Made golint finally happy.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 06 Aug 2022 02:09:57 +0200 |
parents | 9967a78e43f4 |
children | 2dd155cc95ec |
comparison
equal
deleted
inserted
replaced
5600:9967a78e43f4 | 5601:1222b777f51f |
---|---|
34 "gemma.intevation.de/gemma/pkg/xlsx" | 34 "gemma.intevation.de/gemma/pkg/xlsx" |
35 | 35 |
36 "github.com/xuri/excelize/v2" | 36 "github.com/xuri/excelize/v2" |
37 ) | 37 ) |
38 | 38 |
39 // Report is a job to generate a report and send emails to the | |
40 // receivers. | |
39 type Report struct { | 41 type Report struct { |
40 models.QueueConfigurationType | 42 models.QueueConfigurationType |
41 Name models.SafePath `json:"name"` | 43 Name models.SafePath `json:"name"` |
42 } | 44 } |
43 | 45 |
46 // ReportJobKind is the unique name of this import job type. | |
44 const ReportJobKind JobKind = "report" | 47 const ReportJobKind JobKind = "report" |
45 | 48 |
46 type reportJobCreator struct{} | 49 type reportJobCreator struct{} |
47 | 50 |
48 const ( | 51 const ( |
85 } | 88 } |
86 | 89 |
87 // RequiresRoles enforces to be a sys_admin to run this . | 90 // RequiresRoles enforces to be a sys_admin to run this . |
88 func (*Report) RequiresRoles() auth.Roles { return auth.Roles{"sys_admin"} } | 91 func (*Report) RequiresRoles() auth.Roles { return auth.Roles{"sys_admin"} } |
89 | 92 |
93 // Description gives a short info about relevant facts of this import. | |
90 func (r *Report) Description([]string) (string, error) { return string(r.Name), nil } | 94 func (r *Report) Description([]string) (string, error) { return string(r.Name), nil } |
91 | 95 |
96 // CleanUp is an empty implementation. | |
92 func (*Report) CleanUp() error { return nil } | 97 func (*Report) CleanUp() error { return nil } |
93 | 98 |
99 // MarshalAttributes implements a DB marshaling of this job. | |
94 func (r *Report) MarshalAttributes(attrs common.Attributes) error { | 100 func (r *Report) MarshalAttributes(attrs common.Attributes) error { |
95 if err := r.QueueConfigurationType.MarshalAttributes(attrs); err != nil { | 101 if err := r.QueueConfigurationType.MarshalAttributes(attrs); err != nil { |
96 return err | 102 return err |
97 } | 103 } |
98 attrs.Set("name", string(r.Name)) | 104 attrs.Set("name", string(r.Name)) |
99 return nil | 105 return nil |
100 } | 106 } |
101 | 107 |
108 // UnmarshalAttributes implements a DB unmarshaling of this job. | |
102 func (r *Report) UnmarshalAttributes(attrs common.Attributes) error { | 109 func (r *Report) UnmarshalAttributes(attrs common.Attributes) error { |
103 if err := r.QueueConfigurationType.UnmarshalAttributes(attrs); err != nil { | 110 if err := r.QueueConfigurationType.UnmarshalAttributes(attrs); err != nil { |
104 return err | 111 return err |
105 } | 112 } |
106 name, found := attrs.Get("name") | 113 name, found := attrs.Get("name") |
152 } | 159 } |
153 | 160 |
154 return template, action, nil | 161 return template, action, nil |
155 } | 162 } |
156 | 163 |
164 // Do executes the actual report generation. | |
157 func (r *Report) Do( | 165 func (r *Report) Do( |
158 ctx context.Context, | 166 ctx context.Context, |
159 importID int64, | 167 importID int64, |
160 conn *sql.Conn, | 168 conn *sql.Conn, |
161 feedback Feedback, | 169 feedback Feedback, |