(short_url, secret_key=None,
              query_by_code=True, request=None)
return LinkSchema().dump(link).data
For performance benefit its better to calculate id out of short url and
    query long url from the db. Also increments hits counter.

    - To support custom url `query_by_code` flag query db with directly.

    :param short_url: The shortened url.
    :type short_url: string
    :param secret_key: secret key for url
    :param query_by_code: bool to query directly with short url string
    :param request: http request object. When request is not None parse the
        request object and get stats out of it.
    :return: The full url
    :rtype: string
For performance benefit its better to calculate id out of short url and
    query long url from the db. Also increments hits counter.
For performance benefit its better to calculate id out of short url and query long url from the db . Also increments hits counter .
def unshorten(short_url, secret_key=None,
              query_by_code=True, request=None):
    """For performance benefit its better to calculate id out of short url and
    query long url from the db. Also increments hits counter.

    - To support custom url `query_by_code` flag query db with directly.

    :param short_url: The shortened url.
    :type short_url: string
    :param secret_key: secret key for url
    :param query_by_code: bool to query directly with short url string
    :param request: http request object. When request is not None parse the
        request object and get stats out of it.
    :return: The full url
    :rtype: string"""
    url_manager = LinkManager()
    short_path = get_short_path(short_url)
    if query_by_code is True:
        query_dict = dict(short_code=short_path)
    else:
        # TODO: remove this
        _id = HashDigest().decode(short_path)
        query_dict = dict(id=_id)
    link = url_manager.find(**query_dict)
    if link is None:
        raise URLNotFound(short_url)
    if url_manager.has_expired():
        raise LinkExpired
    if link.is_protected:
        if not secret_key or str(link.secret_key) != str(secret_key):
            raise URLAuthFailed(short_url)
    if request:
        save_clickmeta(request, link)
        return link
    return LinkSchema().dump(link).data
def unshorten ( short_url , secret_key = None , query_by_code = True , request = None ) : url_manager = LinkManager ( ) short_path = get_short_path ( short_url ) if query_by_code is True : query_dict = dict ( short_code = short_path ) else : # TODO: remove this _id = HashDigest ( ) . decode ( short_path ) query_dict = dict ( id = _id ) link = url_manager . find ( * * query_dict ) if link is None : raise URLNotFound ( short_url ) if url_manager . has_expired ( ) : raise LinkExpired if link . is_protected : if not secret_key or str ( link . secret_key ) != str ( secret_key ) : raise URLAuthFailed ( short_url ) if request : save_clickmeta ( request , link ) return link return LinkSchema ( ) . dump ( link ) . data