B: Run through testing one more time. Changes reflect test results

This commit is contained in:
Preston Baxter 2023-11-24 02:01:38 -06:00
parent d632f714d0
commit 1ba7327742
8 changed files with 45 additions and 22 deletions

View File

@ -229,6 +229,7 @@ func ScheduleBroadcastFromWebhook(c *gin.Context, body *webhooks.EventDelivery)
UserId: *uid, UserId: *uid,
VendorName: models.PCO_VENDOR_NAME, VendorName: models.PCO_VENDOR_NAME,
VendorId: body.ID, VendorId: body.ID,
CorrelationId: payload.Id,
Type: body.Name, Type: body.Name,
} }
@ -274,6 +275,7 @@ func ScheduleBroadcastFromWebhook(c *gin.Context, body *webhooks.EventDelivery)
UserId: *uid, UserId: *uid,
TriggeringEvent: eventRecievedAudit.MongoId(), TriggeringEvent: eventRecievedAudit.MongoId(),
Result: result, Result: result,
CorrelationId: payload.Id,
VendorName: models.YOUTUBE_VENDOR_NAME, VendorName: models.YOUTUBE_VENDOR_NAME,
} }

View File

@ -1,6 +1,8 @@
package controllers package controllers
import ( import (
"fmt"
"git.preston-baxter.com/Preston_PLB/capstone/frontend-service/templates" "git.preston-baxter.com/Preston_PLB/capstone/frontend-service/templates"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"golang.org/x/text/language" "golang.org/x/text/language"
@ -90,12 +92,15 @@ func eventsRecievedMetricFunction(c *gin.Context) *DashboardMetric {
} }
p := message.NewPrinter(language.English) p := message.NewPrinter(language.English)
return &DashboardMetric{ metric := &DashboardMetric{
Title: "Events Recieved", Title: "Events Recieved",
PrimaryValue: p.Sprintf("%d", totalEvents), PrimaryValue: p.Sprintf("%d", totalEvents),
SecondaryValue: "",
Subtitle: p.Sprintf("Most events came from: %s", events[biggestVendor].Name),
} }
if len(events) > 0 {
metric.Subtitle = fmt.Sprintf("Most events from: %s", events[biggestVendor].Name)
}
return metric
} }
func streamsScheduledMetricFunction(c *gin.Context) *DashboardMetric { func streamsScheduledMetricFunction(c *gin.Context) *DashboardMetric {

View File

@ -28,7 +28,7 @@ func BuildRouter(r *gin.Engine) {
r.Use(cors.Default()) r.Use(cors.Default())
r.Static("/static", "./dist") r.Static("/static", "/var/capstone/dist")
//mainpage //mainpage
r.GET("/", AuthMiddleware(false), LandingPage) r.GET("/", AuthMiddleware(false), LandingPage)

View File

@ -60,7 +60,7 @@ func eventsForUserTableData(c *gin.Context) templates.TableData {
table := make([][]string, len(events)+1) table := make([][]string, len(events)+1)
index := 1 index := 1
for _, event := range events { for _, event := range events {
arr := []string{event.CreatedAt.Format(time.Stamp), strings.ToUpper(event.VendorName), event.VendorId, event.Type} arr := []string{event.CreatedAt.Format(time.Stamp), strings.ToUpper(event.VendorName), event.CorrelationId, event.Type}
if filter_exists { if filter_exists {
//if the filter exists loop through the row. Check if anything meets the filter //if the filter exists loop through the row. Check if anything meets the filter
@ -77,8 +77,8 @@ func eventsForUserTableData(c *gin.Context) templates.TableData {
//We either had no filter or passed the filter check. Add to the pool //We either had no filter or passed the filter check. Add to the pool
table[index] = arr table[index] = arr
index += 1 index += 1
table[0] = []string{"Timestamp", "Vendor", "Id", "Event Type"}
} }
table[0] = []string{"Timestamp", "Vendor", "Id", "Event Type"}
return table[0:index] return table[0:index]
} }
@ -99,7 +99,7 @@ func actionsForUserTableData(c *gin.Context) templates.TableData {
index := 1 index := 1
table := make([][]string, len(actions)+1) table := make([][]string, len(actions)+1)
for _, action := range actions { for _, action := range actions {
arr := []string{action.CreatedAt.Format(time.RFC1123), action.VendorName, action.CorrelationId, action.Result} arr := []string{action.CreatedAt.Format(time.Stamp), action.VendorName, action.CorrelationId, action.Result}
if filter_exists { if filter_exists {
//if the filter exists loop through the row. Check if anything meets the filter //if the filter exists loop through the row. Check if anything meets the filter
pass := false pass := false
@ -112,7 +112,7 @@ func actionsForUserTableData(c *gin.Context) templates.TableData {
continue continue
} }
} }
table[index] = []string{action.CreatedAt.Format(time.RFC1123), action.VendorName, action.CorrelationId, action.Result} table[index] = arr
index += 1 index += 1
} }
table[0] = []string{"Timestamp", "Vendor", "Id", "Result"} table[0] = []string{"Timestamp", "Vendor", "Id", "Result"}

View File

@ -18,6 +18,7 @@ type EventRecieved struct {
UserId primitive.ObjectID `bson:"user_id,omitempty"` //what user is this associated too UserId primitive.ObjectID `bson:"user_id,omitempty"` //what user is this associated too
VendorName string `bson:"vendor_name,omitempty"` //Vendor name of who sent us the event VendorName string `bson:"vendor_name,omitempty"` //Vendor name of who sent us the event
VendorId string `bson:"vendor_id,omitempty"` VendorId string `bson:"vendor_id,omitempty"`
CorrelationId string `bson:"correlation_id,omitempty"` //list of entities effected or created from action
Type string `bson:"type,omitempty"` //type of event Type string `bson:"type,omitempty"` //type of event
} }
@ -34,7 +35,7 @@ func (obj *EventRecieved) UpdateObjectInfo() {
now := time.Now() now := time.Now()
if obj.CommonFields == nil { if obj.CommonFields == nil {
obj.CommonFields = new(CommonFields) obj.CommonFields = new(CommonFields)
obj.EntityType = ACTION_TAKEN_TYPE obj.EntityType = EVENT_RECIEVED_TYPE
obj.CreatedAt = now obj.CreatedAt = now
} }
obj.UpdatedAt = now obj.UpdatedAt = now
@ -64,7 +65,7 @@ func (obj *ActionTaken) UpdateObjectInfo() {
now := time.Now() now := time.Now()
if obj.CommonFields == nil { if obj.CommonFields == nil {
obj.CommonFields = new(CommonFields) obj.CommonFields = new(CommonFields)
obj.EntityType = EVENT_RECIEVED_TYPE obj.EntityType = ACTION_TAKEN_TYPE
obj.CreatedAt = now obj.CreatedAt = now
} }
obj.UpdatedAt = now obj.UpdatedAt = now

View File

@ -132,5 +132,21 @@ func (ts *VendorTokenSource) waitForToken(tl *models.TokenLock) error {
} }
} }
//We waited to long check if its refreshed and carry on
res :=col.FindOne(context.Background(), bson.M{"token_id": tl.TokenId})
if res.Err() != nil {
return errors.Join(TokenWaitExpired, res.Err())
}
err = res.Decode(tl)
if err != nil {
return errors.Join(TokenWaitExpired, res.Err())
}
if tl.Refreshed {
return nil
}
return TokenWaitExpired return TokenWaitExpired
} }

View File

@ -464,7 +464,7 @@ templ DashboardActionsWidget(actions []models.ActionMapping) {
Event Source Event Source
</th> </th>
<th class="px-6 bg-blueGray-50 text-blueGray-500 align-middle border border-solid border-blueGray-100 py-3 text-xs uppercase border-l-0 border-r-0 whitespace-nowrap font-semibold text-left"> <th class="px-6 bg-blueGray-50 text-blueGray-500 align-middle border border-solid border-blueGray-100 py-3 text-xs uppercase border-l-0 border-r-0 whitespace-nowrap font-semibold text-left">
Event Action Action Destination
</th> </th>
<th class="px-6 bg-blueGray-50 text-blueGray-500 align-middle border border-solid border-blueGray-100 py-3 text-xs uppercase border-l-0 border-r-0 whitespace-nowrap font-semibold text-left"> <th class="px-6 bg-blueGray-50 text-blueGray-500 align-middle border border-solid border-blueGray-100 py-3 text-xs uppercase border-l-0 border-r-0 whitespace-nowrap font-semibold text-left">
Action Action
@ -488,10 +488,9 @@ templ DashboardActionsWidget(actions []models.ActionMapping) {
{ action.SourceEvent.Key } { action.SourceEvent.Key }
</th> </th>
<th class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left"> <th class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left">
{ action.Action.VendorName }: { action.Action.Type } { action.Action.VendorName }
</th> </th>
<th class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left"> <th class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left"> { action.Action.Type }
@DashboardActionEditButton(&action)
</th> </th>
</tr> </tr>
} }

View File

@ -1,4 +1,4 @@
{ {
"webhook_version": "0.0.61", "webhook_version": "0.1.8",
"frontend_version": "0.0.42" "frontend_version": "0.1.8"
} }