List Cursor management moved into datastore layer. (#1102)

* Don't try to delete an app that wasn't successfully created in the case of failure

* Allow datastore implementations to inject additional annotations on objects

* Allow for datastores transparently adding annotations on apps, fns and triggers. Change NameIn filter to Name for apps.

* Move *List types including JSON annotations for App, Fn and Trigger into models

* Change return types for GetApps, GetFns and GetTriggers on datastore to
be models.*List and ove cursor generation into datastore

* Trigger cursor handling fixed into db layer

Also changes the name generation so that it is not in the same order
as the id (well is random), this means we are now testing our name ordering.

* GetFns now respects cursors

* Apps now feeds cursor back

* Mock fixes

* Fixing up api level cursor decoding

* Tidy up treatment of cursors in the db layer

* Adding conditions for non nil items lists

* fix mock test
This commit is contained in:
Tom Coupland
2018-06-29 19:14:13 +01:00
committed by Owen Cliffe
parent fca107c815
commit d7139358ce
20 changed files with 522 additions and 240 deletions

View File

@@ -1013,6 +1013,18 @@ func pageParams(c *gin.Context, base64d bool) (cursor string, perPage int) {
return cursor, perPage
}
func pageParamsV2(c *gin.Context) (cursor string, perPage int) {
cursor = c.Query("cursor")
perPage, _ = strconv.Atoi(c.Query("per_page"))
if perPage > 100 {
perPage = 100
} else if perPage <= 0 {
perPage = 30
}
return cursor, perPage
}
type appResponse struct {
Message string `json:"message"`
App *models.App `json:"app"`
@@ -1046,18 +1058,3 @@ type callsResponse struct {
NextCursor string `json:"next_cursor"`
Calls []*models.Call `json:"calls"`
}
type appListResponse struct {
NextCursor string `json:"next_cursor"`
Items []*models.App `json:"items"`
}
type fnListResponse struct {
NextCursor string `json:"next_cursor"`
Items []*models.Fn `json:"items"`
}
type triggerListResponse struct {
NextCursor string `json:"next_cursor"`
Items []*models.Trigger `json:"items"`
}