|
5 | 5 | "DBHS/response" |
6 | 6 | "DBHS/utils" |
7 | 7 | "net/http" |
| 8 | + "strings" |
8 | 9 |
|
9 | 10 | "github.com/gorilla/mux" |
10 | 11 | ) |
@@ -32,14 +33,16 @@ func CurrentStorage(app *config.Application) http.HandlerFunc { |
32 | 33 | } |
33 | 34 |
|
34 | 35 | storage, apiErr := GetALLDatabaseStorage(r.Context(), config.DB, projectOid) |
35 | | - if apiErr.Error() != nil { |
36 | | - utils.ResponseHandler(w, r, apiErr) |
| 36 | + if len(storage) == 0 || (apiErr.Error() != nil && strings.Contains(apiErr.Error().Error(), "cannot scan NULL into")) { |
| 37 | + response.NotFound(w, r, "No storage information found for the project", nil) |
37 | 38 | return |
38 | 39 | } |
39 | | - if len(storage) == 0 { |
40 | | - response.NotFound(w, r, "No storage information found for the project", nil) |
| 40 | + |
| 41 | + if apiErr.Error() != nil { |
| 42 | + utils.ResponseHandler(w, r, apiErr) |
41 | 43 | return |
42 | 44 | } |
| 45 | + |
43 | 46 | response.OK(w, r, "Storage history retrieved successfully", storage) |
44 | 47 | } |
45 | 48 | } |
@@ -67,6 +70,11 @@ func ExecutionTime(app *config.Application) http.HandlerFunc { |
67 | 70 | } |
68 | 71 |
|
69 | 72 | stats, apiErr := GetALLExecutionTimeStats(r.Context(), config.DB, projectOid) |
| 73 | + if len(stats) == 0 || (apiErr.Error() != nil && strings.Contains(apiErr.Error().Error(), "cannot scan NULL into")) { |
| 74 | + response.NotFound(w, r, "No execution time records found for the project", nil) |
| 75 | + return |
| 76 | + } |
| 77 | + |
70 | 78 | if apiErr.Error() != nil { |
71 | 79 | utils.ResponseHandler(w, r, apiErr) |
72 | 80 | return |
@@ -99,6 +107,11 @@ func DatabaseUsage(app *config.Application) http.HandlerFunc { |
99 | 107 | } |
100 | 108 |
|
101 | 109 | stats, apiErr := GetALLDatabaseUsageStats(r.Context(), config.DB, projectOid) |
| 110 | + if len(stats) == 0 || (apiErr.Error() != nil && strings.Contains(apiErr.Error().Error(), "cannot scan NULL into")) { |
| 111 | + response.NotFound(w, r, "No database usage records found for the project", nil) |
| 112 | + return |
| 113 | + } |
| 114 | + |
102 | 115 | if apiErr.Error() != nil { |
103 | 116 | utils.ResponseHandler(w, r, apiErr) |
104 | 117 | return |
|
0 commit comments