MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / databaseList

Function databaseList

cmd/cql-proxy/api/database.go:198–247  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

196}
197
198func databaseList(c *gin.Context) {
199 // query account belongings
200 developer := getDeveloperID(c)
201
202 p, err := model.GetMainAccount(model.GetDB(c), developer)
203 if err != nil {
204 _ = c.Error(err)
205 abortWithError(c, http.StatusForbidden, ErrNoMainAccount)
206 return
207 }
208
209 req := new(types.QueryAccountSQLChainProfilesReq)
210 resp := new(types.QueryAccountSQLChainProfilesResp)
211
212 accountAddr, err := p.Account.Get()
213 if err != nil {
214 _ = c.Error(err)
215 abortWithError(c, http.StatusBadRequest, ErrParseAccountFailed)
216 return
217 }
218
219 req.Addr = accountAddr
220 err = rpc.RequestBP(route.MCCQueryAccountSQLChainProfiles.String(), req, resp)
221 if err != nil {
222 _ = c.Error(err)
223 abortWithError(c, http.StatusInternalServerError, ErrSendETLSRPCFailed)
224 return
225 }
226
227 var profiles []gin.H
228
229 for _, p := range resp.Profiles {
230 var profile = gin.H{}
231
232 for _, user := range p.Users {
233 if user.Address == accountAddr && user.Permission.HasSuperPermission() {
234 profile["id"] = p.ID
235 profile["deposit"] = user.Deposit
236 profile["arrears"] = user.Arrears
237 profile["advance_payment"] = user.AdvancePayment
238
239 profiles = append(profiles, profile)
240 }
241 }
242 }
243
244 responseWithData(c, http.StatusOK, gin.H{
245 "profiles": profiles,
246 })
247}
248
249func createDatabase(db *gorp.DbMap, developer int64, account int64, nodeCount uint16) (tx hash.Hash, dbID proto.DatabaseID, key *asymmetric.PrivateKey, err error) {
250 p, err := model.GetAccountByID(db, developer, account)

Callers

nothing calls this directly

Calls 9

GetMainAccountFunction · 0.92
GetDBFunction · 0.92
getDeveloperIDFunction · 0.85
abortWithErrorFunction · 0.85
responseWithDataFunction · 0.85
ErrorMethod · 0.80
HasSuperPermissionMethod · 0.80
GetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected