Mercurial > gemma
comparison pkg/controllers/report.go @ 5333:6c0f40676984 extented-report
Run xlsx templating in a read-only transaction.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 01 Jun 2021 00:37:03 +0200 |
parents | 348d91848278 |
children | 699048c86848 |
comparison
equal
deleted
inserted
replaced
5332:9df7b39297ed | 5333:6c0f40676984 |
---|---|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> | 12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
13 | 13 |
14 package controllers | 14 package controllers |
15 | 15 |
16 import ( | 16 import ( |
17 "database/sql" | |
17 "fmt" | 18 "fmt" |
18 "log" | 19 "log" |
19 "net/http" | 20 "net/http" |
20 "os" | 21 "os" |
21 "path/filepath" | 22 "path/filepath" |
155 } | 156 } |
156 | 157 |
157 ctx := req.Context() | 158 ctx := req.Context() |
158 conn := middleware.GetDBConn(req) | 159 conn := middleware.GetDBConn(req) |
159 | 160 |
160 if err := action.Execute(ctx, conn, template); err != nil { | 161 tx, err := conn.BeginTx(ctx, &sql.TxOptions{ReadOnly: true}) |
162 defer tx.Rollback() | |
163 | |
164 if err := action.Execute(ctx, tx, template); err != nil { | |
161 log.Printf("error: %v\n", err) | 165 log.Printf("error: %v\n", err) |
162 http.Error(rw, "Error: "+err.Error(), http.StatusInternalServerError) | 166 http.Error(rw, "Error: "+err.Error(), http.StatusInternalServerError) |
163 return | 167 return |
164 } | 168 } |
165 rw.Header().Set( | 169 rw.Header().Set( |