| 703 | } |
| 704 | |
| 705 | func buildFilterAppQuery(filter *models.AppFilter) (string, []interface{}, error) { |
| 706 | var args []interface{} |
| 707 | if filter == nil { |
| 708 | return "", args, nil |
| 709 | } |
| 710 | |
| 711 | var b bytes.Buffer |
| 712 | |
| 713 | if filter.Cursor != "" { |
| 714 | s, err := base64.RawURLEncoding.DecodeString(filter.Cursor) |
| 715 | if err != nil { |
| 716 | return "", args, err |
| 717 | } |
| 718 | args = where(&b, args, "name>?", string(s)) |
| 719 | } |
| 720 | if filter.Name != "" { |
| 721 | args = where(&b, args, "name=?", filter.Name) |
| 722 | } |
| 723 | |
| 724 | fmt.Fprintf(&b, ` ORDER BY name ASC`) // TODO assert this is indexed |
| 725 | fmt.Fprintf(&b, ` LIMIT ?`) |
| 726 | args = append(args, filter.PerPage) |
| 727 | return b.String(), args, nil |
| 728 | } |
| 729 | |
| 730 | func buildFilterFnQuery(filter *models.FnFilter) (string, []interface{}, error) { |
| 731 | if filter == nil { |