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

@ -226,10 +226,11 @@ func ScheduleBroadcastFromWebhook(c *gin.Context, body *webhooks.EventDelivery)
//Save audit point
eventRecievedAudit := &models.EventRecieved{
UserId: *uid,
VendorName: models.PCO_VENDOR_NAME,
VendorId: body.ID,
Type: body.Name,
UserId: *uid,
VendorName: models.PCO_VENDOR_NAME,
VendorId: body.ID,
CorrelationId: payload.Id,
Type: body.Name,
}
if err := mongo.SaveModel(eventRecievedAudit); err != nil {
@ -274,6 +275,7 @@ func ScheduleBroadcastFromWebhook(c *gin.Context, body *webhooks.EventDelivery)
UserId: *uid,
TriggeringEvent: eventRecievedAudit.MongoId(),
Result: result,
CorrelationId: payload.Id,
VendorName: models.YOUTUBE_VENDOR_NAME,
}

View File

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

View File

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

View File

@ -60,7 +60,7 @@ func eventsForUserTableData(c *gin.Context) templates.TableData {
table := make([][]string, len(events)+1)
index := 1
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 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
table[index] = arr
index += 1
table[0] = []string{"Timestamp", "Vendor", "Id", "Event Type"}
}
table[0] = []string{"Timestamp", "Vendor", "Id", "Event Type"}
return table[0:index]
}
@ -99,7 +99,7 @@ func actionsForUserTableData(c *gin.Context) templates.TableData {
index := 1
table := make([][]string, len(actions)+1)
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 the filter exists loop through the row. Check if anything meets the filter
pass := false
@ -112,7 +112,7 @@ func actionsForUserTableData(c *gin.Context) templates.TableData {
continue
}
}
table[index] = []string{action.CreatedAt.Format(time.RFC1123), action.VendorName, action.CorrelationId, action.Result}
table[index] = arr
index += 1
}
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
VendorName string `bson:"vendor_name,omitempty"` //Vendor name of who sent us the event
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
}
@ -34,7 +35,7 @@ func (obj *EventRecieved) UpdateObjectInfo() {
now := time.Now()
if obj.CommonFields == nil {
obj.CommonFields = new(CommonFields)
obj.EntityType = ACTION_TAKEN_TYPE
obj.EntityType = EVENT_RECIEVED_TYPE
obj.CreatedAt = now
}
obj.UpdatedAt = now
@ -64,7 +65,7 @@ func (obj *ActionTaken) UpdateObjectInfo() {
now := time.Now()
if obj.CommonFields == nil {
obj.CommonFields = new(CommonFields)
obj.EntityType = EVENT_RECIEVED_TYPE
obj.EntityType = ACTION_TAKEN_TYPE
obj.CreatedAt = 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
}

View File

@ -464,7 +464,7 @@ templ DashboardActionsWidget(actions []models.ActionMapping) {
Event Source
</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">
Event Action
Action Destination
</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">
Action
@ -488,10 +488,9 @@ templ DashboardActionsWidget(actions []models.ActionMapping) {
{ action.SourceEvent.Key }
</th>
<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 class="border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4 text-left">
@DashboardActionEditButton(&action)
<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 }
</th>
</tr>
}

View File

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