Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The LUCI Authors. | 1 // Copyright 2015 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 // Alias, if true, means that this link is an [alias link]. | 278 // Alias, if true, means that this link is an [alias link]. |
| 279 Alias bool `json:",omitempty"` | 279 Alias bool `json:",omitempty"` |
| 280 } | 280 } |
| 281 | 281 |
| 282 // NewLink does just about what you'd expect. | 282 // NewLink does just about what you'd expect. |
| 283 func NewLink(label, url string) *Link { | 283 func NewLink(label, url string) *Link { |
| 284 return &Link{Link: model.Link{Label: label, URL: url}} | 284 return &Link{Link: model.Link{Label: label, URL: url}} |
| 285 } | 285 } |
| 286 | 286 |
| 287 func (comp *BuildComponent) toModelSummary() model.Summary { | 287 func (comp *BuildComponent) toModelSummary() model.Summary { |
| 288 text := comp.Text | |
| 289 // Max length for a datastore text field is 1500 char, but for summary p urposes | |
| 290 // 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
| |
| 291 const maxTextLen = 256 | |
| 292 if len(text) > maxTextLen { | |
| 293 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
| |
| 294 } | |
| 288 return model.Summary{ | 295 return model.Summary{ |
| 289 Status: comp.Status, | 296 Status: comp.Status, |
| 290 Start: comp.Started, | 297 Start: comp.Started, |
| 291 End: comp.Finished, | 298 End: comp.Finished, |
| 292 » » Text: comp.Text, | 299 » » Text: text, |
| 293 } | 300 } |
| 294 } | 301 } |
| 295 | 302 |
| 296 // SummarizeTo summarizes the data into a given model.BuildSummary. | 303 // SummarizeTo summarizes the data into a given model.BuildSummary. |
| 297 func (rb *MiloBuild) SummarizeTo(c context.Context, bs *model.BuildSummary) erro r { | 304 func (rb *MiloBuild) SummarizeTo(c context.Context, bs *model.BuildSummary) erro r { |
| 298 bs.Summary = rb.Summary.toModelSummary() | 305 bs.Summary = rb.Summary.toModelSummary() |
| 299 if rb.Summary.Status == model.Running { | 306 if rb.Summary.Status == model.Running { |
| 300 // Assume the last step is the current step. | 307 // Assume the last step is the current step. |
| 301 if len(rb.Components) > 0 { | 308 if len(rb.Components) > 0 { |
| 302 cs := rb.Components[len(rb.Components)-1] | 309 cs := rb.Components[len(rb.Components)-1] |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 330 } | 337 } |
| 331 if rb.SourceStamp.Changelist != nil { | 338 if rb.SourceStamp.Changelist != nil { |
| 332 bs.Patches = append(bs.Patches, model.PatchInfo{ | 339 bs.Patches = append(bs.Patches, model.PatchInfo{ |
| 333 Link: rb.SourceStamp.Changelist.Link, | 340 Link: rb.SourceStamp.Changelist.Link, |
| 334 AuthorEmail: rb.SourceStamp.AuthorEmail, | 341 AuthorEmail: rb.SourceStamp.AuthorEmail, |
| 335 }) | 342 }) |
| 336 } | 343 } |
| 337 } | 344 } |
| 338 return nil | 345 return nil |
| 339 } | 346 } |
| OLD | NEW |