from api_graphql.abc.db_model_query_abc import DbModelQueryABC
from data.schemas.public.short_url_dao import shortUrlDao


class ShortUrlQuery(DbModelQueryABC):
    def __init__(self):
        DbModelQueryABC.__init__(self, "ShortUrl", shortUrlDao, with_history=True)

        self.set_field("shortUrl", lambda x, *_: x.short_url)
        self.set_field("targetUrl", lambda x, *_: x.target_url)
        self.set_field("description", lambda x, *_: x.description)
        self.set_field("visits", lambda x, *_: x.visit_count)
        self.set_field("loadingScreen", lambda x, *_: x.loading_screen)

        self.set_field("group", lambda x, *_: x.group)
        self.set_field("domain", lambda x, *_: x.domain)

        self.set_field("userSpace", lambda x, *_: x.user_space)
