Esempio n. 1
0
    def get_data(self, **params):
        data = {}
        hostname = params.get('hostname')
        hostuiname = ''
        order_by = params.get('order_by', '1')
        limit = params.get('limit', '50')
        from_date = params.get('from_date',
                               datetime.datetime.now().strftime('%Y-%m-%d'))
        to_date = params.get('to_date',
                             (datetime.datetime.now() +
                              datetime.timedelta(1)).strftime('%Y-%m-%d'))
        no_copy_ddl = params.get('no_copy_ddl', True)
        min_calls = params.get('min_calls', '3')

        if 'show' in params and hostname:
            data = reportdata.getStatStatements(hostname, from_date, to_date,
                                                order_by, limit, no_copy_ddl,
                                                min_calls)
            hostuiname = hosts.getHostUIShortnameByHostname(hostname)
        for d in data:
            d['query_short'] = d['query'][:60].replace('\n', ' ').replace(
                '\t', ' ') + ('...' if len(d['query']) > 60 else '')

        host_names = sorted(hosts.hosts.items(),
                            key=lambda h: h[1]['host_name'])
        return hostname, host_names, hostuiname, data, from_date, to_date, order_by, limit, no_copy_ddl, min_calls
Esempio n. 2
0
    def get_data(self, selected_hostname=None, **params):
        hostnames = hosts.getAllHostNames()
        bloat_type = params.get('bloat_type', 'table')
        order_by = params.get('order_by', 'wasted_bytes')
        limit = params.get('limit', '50')
        data = []
        hostuiname = None
        if selected_hostname:
            if bloat_type == 'table':
                msg, data = reportdata.getBloatedTablesForHostname(selected_hostname, order_by, limit)
            else:
                msg, data = reportdata.getBloatedIndexesForHostname(selected_hostname, order_by, limit)
            if msg:
                raise Exception('Failed to get data: ' + msg)
            hostuiname = hosts.getHostUIShortnameByHostname(selected_hostname)

        return data, hostnames, bloat_type, order_by, limit, hostuiname
Esempio n. 3
0
    def get_data(self, **params):
        data = {}
        hostname = params.get('hostname')
        hostuiname = ''
        order_by = params.get('order_by', '1')
        limit = params.get('limit', '50')
        from_date = params.get('from_date', datetime.datetime.now().strftime('%Y-%m-%d'))
        to_date = params.get('to_date', (datetime.datetime.now() + datetime.timedelta(1)).strftime('%Y-%m-%d'))

        if 'show' in params and hostname:
            data = reportdata.getStatStatements(hostname, from_date, to_date, order_by, limit)
            hostuiname = hosts.getHostUIShortnameByHostname(hostname)
        for d in data:
            d['query_short'] = d['query'][:60].replace('\n',' ').replace('\t',' ') + ('...' if len(d['query']) > 60 else '')

        host_names=sorted(hosts.hosts.items(), key = lambda h : h[1]['host_name'])
        return hostname, host_names, hostuiname, data, from_date, to_date, order_by, limit
Esempio n. 4
0
    def get_data(self, selected_hostname=None, **params):
        hostnames = hosts.getAllHostNames()
        bloat_type = params.get('bloat_type', 'table')
        order_by = params.get('order_by', 'wasted_bytes')
        limit = params.get('limit', '50')
        data = []
        hostuiname = None
        if selected_hostname:
            if bloat_type == 'table':
                msg, data = reportdata.getBloatedTablesForHostname(selected_hostname, order_by, limit)
            else:
                msg, data = reportdata.getBloatedIndexesForHostname(selected_hostname, order_by, limit)
            if msg:
                raise Exception('Failed to get data: ' + msg)
            hostuiname = hosts.getHostUIShortnameByHostname(selected_hostname)

        return data, hostnames, bloat_type, order_by, limit, hostuiname