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

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

Issue 2993623002: Milo: Limit text field to 256 characters (Closed)
Patch Set: Typo 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..e92c94b8825d4d550b8bb471fea5722f36cfe593 100644
--- a/milo/api/resp/build.go
+++ b/milo/api/resp/build.go
@@ -285,11 +285,18 @@ 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 200 char or so.
dnj 2017/08/03 16:28:20 s/200/256?
Ryan Tseng 2017/08/03 16:32:58 I was trying to highlight the inexact nature of wh
+ const maxTextLen = 256
+ if len(text) > maxTextLen {
+ text = text[0:256]
dnj 2017/08/03 16:28:20 nit: can just do text[:256]. However, there is a
Ryan Tseng 2017/08/03 16:32:58 Weird, Go used to complain if I did [:number] don
+ }
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