icon url added: GWM
This commit is contained in:
parent
89f8e1c515
commit
f841fd8952
29
main.go
29
main.go
@ -2126,13 +2126,15 @@ func main() {
|
||||
Rank float64 `db:"rank" json:"rank"`
|
||||
IsRankPositive bool `db:"is_rank_positive" json:"is_rank_positive"`
|
||||
RankHeading string `db:"rank_heading" json:"rank_heading"`
|
||||
Icon string `db:"icon" json:"icon"`
|
||||
IconURL string `db:"-" json:"icon_url"`
|
||||
}{}
|
||||
|
||||
topicColumn := "topic_" + language
|
||||
valueColumn := "value_" + language
|
||||
rankHeadingColumn := "rank_heading_" + language
|
||||
|
||||
query3 := `SELECT id,type,` + topicColumn + ` AS topic,` + valueColumn + ` AS value,` + rankHeadingColumn + ` AS rank_heading,rank,is_rank_positive FROM country_statistics WHERE country = {:country} ORDER BY type ASC, rank ASC`
|
||||
query3 := `SELECT id,type,` + topicColumn + ` AS topic,` + valueColumn + ` AS value,` + rankHeadingColumn + ` AS rank_heading,rank,is_rank_positive,icon FROM country_statistics WHERE country = {:country} ORDER BY type ASC, rank ASC`
|
||||
|
||||
err = app.DB().
|
||||
NewQuery(query3).
|
||||
@ -2145,6 +2147,19 @@ func main() {
|
||||
log.Printf("Failed to fetch statistics: %v", err)
|
||||
}
|
||||
|
||||
for i := range allStatistics {
|
||||
if allStatistics[i].Icon == "" {
|
||||
allStatistics[i].IconURL = ""
|
||||
continue
|
||||
}
|
||||
|
||||
allStatistics[i].IconURL = fmt.Sprintf("%s/api/files/country_statistics/%s/%s",
|
||||
baseUrl,
|
||||
allStatistics[i].ID,
|
||||
allStatistics[i].Icon,
|
||||
)
|
||||
}
|
||||
|
||||
// Group statistics by type
|
||||
statisticsMap := map[string]interface{}{
|
||||
"demography": []interface{}{},
|
||||
@ -2497,7 +2512,7 @@ func main() {
|
||||
}
|
||||
data, _ := json.Marshal(loginPayload)
|
||||
|
||||
loginReq, _ := http.NewRequest("POST", fmt.Sprintf("%s/api/admins/auth-with-password", "https://pb.venbait.in"), bytes.NewBuffer(data))
|
||||
loginReq, _ := http.NewRequest("POST", fmt.Sprintf("%s/api/admins/auth-with-password", "http://127.0.0.1:8090"), bytes.NewBuffer(data))
|
||||
loginReq.Header.Set("Content-Type", "application/json")
|
||||
|
||||
loginResp, err := http.DefaultClient.Do(loginReq)
|
||||
@ -2518,7 +2533,7 @@ func main() {
|
||||
}
|
||||
|
||||
// 2️⃣ Use token to fetch records
|
||||
url := fmt.Sprintf("%s/api/collections/%s/records?perPage=500", "https://pb.venbait.in", reqBody.Collection)
|
||||
url := fmt.Sprintf("%s/api/collections/%s/records?perPage=500", "http://127.0.0.1:8090", reqBody.Collection)
|
||||
fmt.Println("Fetching collection from URL:", url)
|
||||
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
@ -2567,10 +2582,10 @@ func main() {
|
||||
"password": reqBody.LivePassword,
|
||||
}
|
||||
data, _ := json.Marshal(livePayload)
|
||||
liveReq, _ := http.NewRequest("POST", fmt.Sprintf("%s/api/admins/auth-with-password", "https://pocket.fcsc.gov.ae"), bytes.NewBuffer(data))
|
||||
liveReq, _ := http.NewRequest("POST", fmt.Sprintf("%s/api/admins/auth-with-password", "https://pb.venbait.in"), bytes.NewBuffer(data))
|
||||
liveReq.Header.Set("Content-Type", "application/json")
|
||||
liveResp, err := http.DefaultClient.Do(liveReq)
|
||||
fmt.Println("Live url:", "https://pocket.fcsc.gov.ae")
|
||||
fmt.Println("Live url:", "https://pb.venbait.in")
|
||||
fmt.Println("Live req:", liveReq)
|
||||
if err != nil {
|
||||
return c.JSON(500, map[string]string{"error": "failed to connect to Live PB"})
|
||||
@ -2593,7 +2608,7 @@ func main() {
|
||||
data, _ := json.Marshal(rec)
|
||||
|
||||
// Try PATCH first
|
||||
patchURL := fmt.Sprintf("%s/api/collections/%s/records/%s", "https://pocket.fcsc.gov.ae", reqBody.Collection, id)
|
||||
patchURL := fmt.Sprintf("%s/api/collections/%s/records/%s", "https://pb.venbait.in", reqBody.Collection, id)
|
||||
req, _ := http.NewRequest("PATCH", patchURL, bytes.NewBuffer(data))
|
||||
req.Header.Set("Authorization", liveLogin.Token)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
@ -2607,7 +2622,7 @@ func main() {
|
||||
|
||||
if resp.StatusCode == 404 {
|
||||
// Create instead
|
||||
postURL := fmt.Sprintf("%s/api/collections/%s/records", "https://pocket.fcsc.gov.ae", reqBody.Collection)
|
||||
postURL := fmt.Sprintf("%s/api/collections/%s/records", "https://pb.venbait.in", reqBody.Collection)
|
||||
req, _ := http.NewRequest("POST", postURL, bytes.NewBuffer(data))
|
||||
req.Header.Set("Authorization", liveLogin.Token)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
BIN
pb_data/data.db
BIN
pb_data/data.db
Binary file not shown.
Binary file not shown.
BIN
pb_data/logs.db
BIN
pb_data/logs.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
@ -0,0 +1 @@
|
||||
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/png","user.metadata":null,"md5":"EQ0c1eYViGoivgx7b8rwQw=="}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@ -0,0 +1 @@
|
||||
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/png","user.metadata":{"original-filename":"Venba Infotech.png"},"md5":"P55jVi+THe+NP1tG4KgsSw=="}
|
||||
Loading…
Reference in New Issue
Block a user