Example #1
0
    def get(self, dash_id):
        """Read dashboard content.

        Args:
            dash_id: dashboard id.

        Returns:
            A dict containing the content of that dashboard, not include the meta info.
        """
        data = json.loads(r_db.hmget(config.DASH_CONTENT_KEY, dash_id)[0])
        return build_response(dict(data=data, code=200))
Example #2
0
    def get(self, dash_id):
        """Read dashboard content.

        Args:
            dash_id: dashboard id.

        Returns:
            A dict containing the content of that dashboard, not include the meta info.
        """
        data = json.loads(r_db.hmget(config.DASH_CONTENT_KEY, dash_id)[0])
        return build_response(dict(data=data, code=200))
Example #3
0
    def get(self, page=0, size=10):
        """Get dashboard meta info from in page `page` and page size is `size`.

        Args:
            page: page number.
            size: size number.

        Returns:
            list of dict containing the dash_id and accordingly meta info.
            maybe empty list [] when page * size > total dashes in db. that's reasonable.
        """
        dash_list = r_db.zrevrange(config.DASH_ID_KEY, 0, -1, True)
        id_list = dash_list[page * size : page * size + size]
        dash_meta = []
        data = []
        if id_list:
            dash_meta = r_db.hmget(config.DASH_META_KEY, [i[0] for i in id_list])
            data = [json.loads(i) for i in dash_meta]

        return build_response(dict(data=data, code=200))
Example #4
0
    def get(self, page=0, size=10):
        """Get dashboard meta info from in page `page` and page size is `size`.

        Args:
            page: page number.
            size: size number.

        Returns:
            list of dict containing the dash_id and accordingly meta info.
            maybe empty list [] when page * size > total dashes in db. that's reasonable.
        """
        dash_list = r_db.zrevrange(config.DASH_ID_KEY, 0, -1, True)
        id_list = dash_list[page * size:page * size + size]
        dash_meta = []
        data = []
        if id_list:
            dash_meta = r_db.hmget(config.DASH_META_KEY,
                                   [i[0] for i in id_list])
            data = [json.loads(i) for i in dash_meta]

        return build_response(dict(data=data, code=200))