Skip to content
Snippets Groups Projects
Commit f2db2510 authored by Martin Iversen's avatar Martin Iversen
Browse files

Merge branch 'Martin' into 'main'

Martin

See merge request !108
parents 31d3a9a4 6c777483
Branches
No related tags found
1 merge request!108Martin
......@@ -20,11 +20,9 @@ var Client *firestore.Client
//Code taken from https://firebase.google.com/docs/firestore/quickstart#go
func DatabaseConnection() {
file, err := filepath.Abs("database/stillas-16563-firebase-adminsdk-wd82v-a9fe8919b7.json")
if err != nil {
log.Fatal(err)
}
// Creates instance of firebase
Ctx = context.Background()
sa := option.WithCredentialsFile(file) //Initializes database
......@@ -72,7 +70,6 @@ GetDocumentData inspired from https://firebase.google.com/docs/firestore/query-d
The function will return a selected document from a selected collection.
document is the path to the selected document.
*/
func GetDocumentData(document *firestore.DocumentRef) (map[string]interface{}, error) {
dsnap, err := document.Get(Ctx)
if err != nil {
......
......@@ -59,7 +59,6 @@ func Handle() {
//Gateway POST request endpoint (Only used for registering tags)
router.HandleFunc(baseURL+"/gateway/input", UpdatePosition)
http.Handle("/", router)
InfoLogger.Println(http.ListenAndServe(getPort(), nil))
}
......
......@@ -721,7 +721,7 @@ func addScaffolding(documentPath *firestore.DocumentRef, batch *firestore.WriteB
scaffoldingTypeDocument := scaffoldingCollection.Doc(scaffoldingType)
scaffoldingStruct := _struct.Scaffolding{
Type: (scaffoldingType),
Type: scaffoldingType,
Quantity: _struct.Quantity{
Expected: 0,
Registered: 0,
......
......@@ -166,7 +166,6 @@ func deletePart(w http.ResponseWriter, r *http.Request) {
tool.HandleError(tool.ENCODINGERROR, w)
return
}
}
//getQuantity Function takes an object of scaffolding type in storage and returns the expected amount and registered quantity
......@@ -253,12 +252,10 @@ func getAllScaffoldingParts(w http.ResponseWriter) {
if err == iterator.Done {
break
}
if err != nil {
tool.HandleError(tool.COLLECTIONITERATORERROR, w)
return
}
document := database.Client.Collection(constants.S_TrackingUnitCollection).Doc(constants.S_ScaffoldingParts).Collection(scaffoldingType.ID).Documents(database.Ctx)
for {
partRef, err := document.Next()
......
......@@ -62,6 +62,7 @@ func UpdatePosition(w http.ResponseWriter, r *http.Request) {
printList = append(printList, "\nTag id:"+idList[i]+" Battery voltage: "+battery+"\n")
}
updateAmountProject(gatewayList[0].Gateway(), w, idList, batteryList)
fmt.Printf("\n-----------------------------------------------------")
fmt.Println("\nBeacon payload:")
......@@ -70,8 +71,6 @@ func UpdatePosition(w http.ResponseWriter, r *http.Request) {
fmt.Printf("Amount of tags registered: %v \n", len(idList))
fmt.Printf("List of tags:\n %v", printList)
fmt.Printf("\n-----------------------------------------------------\n")
updateAmountProject(gatewayList[0].Gateway(), w, idList, batteryList)
}
func updateAmountProject(beaconID string, w http.ResponseWriter, idList []string, batteryList map[string]float32) {
......@@ -224,7 +223,6 @@ func getTagTypes(idList []string, projectName string, scaffoldingArray _struct.S
resultList := make(map[string]int)
var scaffoldingType string
for i := range idList {
for j := range scaffoldingArray {
scaffoldingType = scaffoldingArray[j].Type
documentPath := database.Client.Collection(constants.S_TrackingUnitCollection).Doc(constants.S_ScaffoldingParts).Collection(scaffoldingType).Doc(idList[i])
......
......@@ -4,8 +4,7 @@ Nettverk brukernavn martiiv@stud.ntnu.no
Nettverk passord samme som vanlig
sudo docker build . -t scaffoldingtracker
sudo docker run -d --name scaffolding0.4 -p 8080:8080 scaffoldingtracker
19
Krisetilfellet:
package endpoints
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment