databroker: add support for querying the databroker (#1443)

* databroker: add support for querying the databroker

* remove query method, use getall so encryption works

* add test

* return early
This commit is contained in:
Caleb Doxsey 2020-09-22 16:01:37 -06:00 committed by GitHub
parent fdec45fe04
commit 2364da14c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 534 additions and 118 deletions

View file

@ -5,3 +5,17 @@ package databroker
func GetUserID(provider, providerUserID string) string {
return provider + "/" + providerUserID
}
// ApplyOffsetAndLimit applies the offset and limit to the list of records.
func ApplyOffsetAndLimit(all []*Record, offset, limit int) (records []*Record, totalCount int) {
records = all
if offset < len(records) {
records = records[offset:]
} else {
records = nil
}
if limit <= len(records) {
records = records[:limit]
}
return records, len(all)
}