(t *adminv1.MagicAuthToken)
| 450 | } |
| 451 | |
| 452 | func toMagicAuthTokenRow(t *adminv1.MagicAuthToken) *magicAuthToken { |
| 453 | filters := "" |
| 454 | for mv, filter := range t.MetricsViewFilters { |
| 455 | expr := metricsview.NewExpressionFromProto(filter) |
| 456 | sqlFilter, err := metricsview.ExpressionToSQL(expr) |
| 457 | if err != nil { |
| 458 | panic(err) |
| 459 | } |
| 460 | if filters != "" { |
| 461 | filters += ", " |
| 462 | } |
| 463 | filters += fmt.Sprintf("%s(%s)", mv, sqlFilter) |
| 464 | } |
| 465 | |
| 466 | row := &magicAuthToken{ |
| 467 | ID: t.Id, |
| 468 | MetricsViewFilters: filters, |
| 469 | CreatedBy: t.CreatedByUserEmail, |
| 470 | CreatedOn: t.CreatedOn.AsTime().Local().Format(time.DateTime), |
| 471 | UsedOn: t.UsedOn.AsTime().Local().Format(time.DateTime), |
| 472 | } |
| 473 | if t.ExpiresOn != nil { |
| 474 | row.ExpiresOn = t.ExpiresOn.AsTime().Local().Format(time.DateTime) |
| 475 | } |
| 476 | return row |
| 477 | } |
| 478 | |
| 479 | type magicAuthToken struct { |
| 480 | ID string `header:"id" json:"id"` |
no test coverage detected