-
Notifications
You must be signed in to change notification settings - Fork 563
/
Copy pathdashboard.go
32 lines (27 loc) · 948 Bytes
/
dashboard.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package controllers
import (
"errors"
"github.com/diggerhq/digger/backend/middleware"
"github.com/diggerhq/digger/backend/models"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"log"
"net/http"
)
func GetDashboardStatusApi(c *gin.Context) {
organisationId := c.GetString(middleware.ORGANISATION_ID_KEY)
organisationSource := c.GetString(middleware.ORGANISATION_SOURCE_KEY)
var org models.Organisation
err := models.DB.GormDB.Where("external_id = ? AND external_source = ?", organisationId, organisationSource).First(&org).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
c.String(http.StatusNotFound, "Could not find organisation: "+organisationId)
} else {
log.Printf("could not fetch organisation: %v err: %v", organisationId, err)
c.String(http.StatusNotFound, "Could not fetch organisation: "+organisationId)
}
return
}
response := make(map[string]interface{})
c.JSON(http.StatusOK, response)
}