@classmethod
    def field_by_prefix(cls, field, prefix=''):
        # unichr(0xfff8) is something close to the highest character available
        res = cls.view("domain/fields_by_prefix",
                       group=True,
                       startkey=[field, True, prefix],
                       endkey=[field, True, "%s%c" % (prefix, unichr(0xfff8)), {}])
        vals = [(d['value'], d['key'][2]) for d in res]
        vals.sort(reverse=True)
        return [(v[1], v[0]) for v in vals]
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/domain/models.py/Domain.field_by_prefix/original