refactor: Update ARR body parsing logic

The code changes in `pattern_test.go` update the ARR body parsing logic. The message body parsing now correctly handles ARR bodies with a different pattern format. This ensures accurate extraction of data based on patterns and improves the overall functionality of the code.
This commit is contained in:
windyboy
2024-07-24 11:07:04 +08:00
parent 496dc2b9d0
commit 738ce16f34
8 changed files with 196 additions and 149 deletions
+4 -2
View File
@@ -3,10 +3,10 @@ package repository
import (
"context"
"encoding/json"
"fmt"
"os"
"caatsm/internal/domain"
"caatsm/pkg/utils"
"github.com/Khan/genqlient/graphql"
"github.com/google/uuid"
@@ -30,6 +30,7 @@ func NewHasuraRepo(endpoint, secret string) *HasuraRepository {
// InsertParsedMessage inserts a new ParsedMessage into the Hasura GraphQL API
func (hr *HasuraRepository) CreateNew(pm *domain.ParsedMessage) error {
log := utils.GetSugaredLogger()
bodyString, _ := json.Marshal(pm.BodyData)
secondAddress, _ := json.Marshal(pm.SecondaryAddresses)
variables := Aviation_telegrams_insert_input{
@@ -51,6 +52,7 @@ func (hr *HasuraRepository) CreateNew(pm *domain.ParsedMessage) error {
if err != nil {
return err
}
fmt.Printf("Inserted new message: %v\n", resp)
// fmt.Printf("Inserted new message: %v\n", resp)
log.Infof("Saved : %v\n", resp)
return nil
}