diff --git a/main.go b/main.go index f9bc773..d10df64 100755 --- a/main.go +++ b/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") diff --git a/pb_data/data.db b/pb_data/data.db index e4f29dc..95c9ccb 100644 Binary files a/pb_data/data.db and b/pb_data/data.db differ diff --git a/pb_data/data.db-shm b/pb_data/data.db-shm deleted file mode 100644 index fe9ac28..0000000 Binary files a/pb_data/data.db-shm and /dev/null differ diff --git a/pb_data/data.db-wal b/pb_data/data.db-wal deleted file mode 100644 index e69de29..0000000 diff --git a/pb_data/logs.db b/pb_data/logs.db index 239cb77..ce94a0b 100644 Binary files a/pb_data/logs.db and b/pb_data/logs.db differ diff --git a/pb_data/logs.db-shm b/pb_data/logs.db-shm deleted file mode 100644 index fe9ac28..0000000 Binary files a/pb_data/logs.db-shm and /dev/null differ diff --git a/pb_data/logs.db-wal b/pb_data/logs.db-wal deleted file mode 100644 index e69de29..0000000 diff --git a/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/thumbs_venba_infotech_WedEVqrMFU.png/100x100_venba_infotech_WedEVqrMFU.png b/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/thumbs_venba_infotech_WedEVqrMFU.png/100x100_venba_infotech_WedEVqrMFU.png new file mode 100644 index 0000000..36cbbfa Binary files /dev/null and b/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/thumbs_venba_infotech_WedEVqrMFU.png/100x100_venba_infotech_WedEVqrMFU.png differ diff --git a/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/thumbs_venba_infotech_WedEVqrMFU.png/100x100_venba_infotech_WedEVqrMFU.png.attrs b/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/thumbs_venba_infotech_WedEVqrMFU.png/100x100_venba_infotech_WedEVqrMFU.png.attrs new file mode 100644 index 0000000..78ff8fe --- /dev/null +++ b/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/thumbs_venba_infotech_WedEVqrMFU.png/100x100_venba_infotech_WedEVqrMFU.png.attrs @@ -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=="} diff --git a/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/venba_infotech_WedEVqrMFU.png b/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/venba_infotech_WedEVqrMFU.png new file mode 100644 index 0000000..94940ef Binary files /dev/null and b/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/venba_infotech_WedEVqrMFU.png differ diff --git a/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/venba_infotech_WedEVqrMFU.png.attrs b/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/venba_infotech_WedEVqrMFU.png.attrs new file mode 100644 index 0000000..3fad2ec --- /dev/null +++ b/pb_data/storage/1x3169aal6ch7z8/r764480e13bf71a/venba_infotech_WedEVqrMFU.png.attrs @@ -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=="}