Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: milo/api/resp/build.go

Issue 2993623002: Milo: Limit text field to 256 characters (Closed)
Patch Set: go fmt Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/api/resp/build.go
diff --git a/milo/api/resp/build.go b/milo/api/resp/build.go
index 174f328f23bcb78db9c004d9d3f524c70170d9aa..9c7e9685641a304801633ef64fcd1dfff70567e3 100644
--- a/milo/api/resp/build.go
+++ b/milo/api/resp/build.go
@@ -285,11 +285,24 @@ func NewLink(label, url string) *Link {
}
func (comp *BuildComponent) toModelSummary() model.Summary {
+ text := comp.Text
+ // Max length for a datastore text field is 1500 char, but for summary purposes
+ // we don't really need anything much longer than 256 char or so.
+ const maxTextLen = 256
+ sliceIdx := 0
+ // Make sure we don't cut off characters inbetween runes.
+ for idx := range text {
+ if idx > maxTextLen {
+ break
+ }
+ sliceIdx = idx
+ }
+ text = text[:sliceIdx]
return model.Summary{
Status: comp.Status,
Start: comp.Started,
End: comp.Finished,
- Text: comp.Text,
+ Text: text,
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698