You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/02/20 14:15:47 UTC

[GitHub] rabbah commented on a change in pull request #116: Added extra columns to activation records summary rows

rabbah commented on a change in pull request #116: Added extra columns to activation records summary rows
URL: https://github.com/apache/incubator-openwhisk-client-go/pull/116#discussion_r258499435
 
 

 ##########
 File path: whisk/activation.go
 ##########
 @@ -80,14 +85,58 @@ func (activation Activation) Compare(sortable Sortable) bool {
 
 // ToHeaderString() returns the header for a list of activations
 func (activation Activation) ToHeaderString() string {
-	return fmt.Sprintf("%s\n", "activations")
+	return fmt.Sprintf("%-19s %-32s %-20s %-6s%-10s %-17s %-100s\n", "Datetime", "Activation ID", "Kind", "Start", "Duration", "Status", "Entity")
+}
+
+// TruncateStr() returns the string, truncated with ...in the middle if it exceeds the specified length
+func TruncateStr(str string, maxlen int) string {
+	if len(str) <= maxlen {
+		return str
+	} else {
+		mid := maxlen / 2
+		upp := len(str) - mid + 3
+		if maxlen%2 != 0 {
+			mid++
+		}
+		return str[0:mid] + "..." + str[upp:]
+	}
 }
 
 // ToSummaryRowString() returns a compound string of required parameters for printing
 //   from CLI command `wsk activation list`.
 // ***Method of type Sortable***
 func (activation Activation) ToSummaryRowString() string {
-	return fmt.Sprintf("%s %-20s\n", activation.ActivationID, activation.Name)
+	s := time.Unix(0, activation.Start*1000000)
+	e := time.Unix(0, activation.End*1000000)
+
+	var duration = e.Sub(s)
+	var kind interface{} = activation.Annotations.GetValue("kind")
+	var initTime interface{} = activation.Annotations.GetValue("initTime")
+	var status = statusCodes[0] // assume success
+	var start = "warm"          // assume warm
+
+	if activation.Duration == 0 {
+		duration = s.Sub(s)
+	}
+	if kind == nil {
+		kind = "unknown"
+	}
+	if activation.StatusCode > 0 && activation.StatusCode <= 3 {
+		status = statusCodes[activation.StatusCode]
+	}
+	if initTime != nil {
+		start = "cold"
 
 Review comment:
   initTime is only present for a cold activation, so this works.
   
   👍 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services