Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom preset for table filter (configable via QueryConfig) #197

Open
duyet opened this issue Apr 1, 2024 · 1 comment
Open

Custom preset for table filter (configable via QueryConfig) #197

duyet opened this issue Apr 1, 2024 · 1 comment

Comments

@duyet
Copy link
Owner

duyet commented Apr 1, 2024

Custom preset for table filter (configable via QueryConfig)

@duyet
Copy link
Owner Author

duyet commented Sep 28, 2024

Done implement, example usage with defaultParams and filterParamPresets:

import { ColumnFormat } from '@/types/column-format'
import { type QueryConfig } from '@/types/query-config'

export const historyQueriesConfig: QueryConfig = {
  name: 'history-queries',
  description:
    'Contains information about executed queries: start time, duration of processing, error messages',
  sql: `
      SELECT ...
      FROM system.query_log
      WHERE
        if ({type: String} != '', type = {type: String}, type != 'QueryStart')
        AND if ({duration_1m: String} = '1', query_duration >= 60, true)
        AND if ({event_time: String} != '', toDate(event_time) = toDate({event_time: String}), true)
        AND if ({database: String} != '' AND {table: String} != '', has(tables, format('{}.{}', {database: String}, {table: String})), true)
      ORDER BY event_time DESC
      LIMIT 1000
  `,

  columns: [ ... ],
  columnFormats: { ... },

  defaultParams: {
    type: '',
    duration_1m: '',
    event_time: '',
    database: '',
    table: '',
  },

  filterParamPresets: [
    {
      name: 'type = QueryStart',
      key: 'type',
      value: 'QueryStart',
    },
    {
      name: 'query_duration > 1m',
      key: 'duration_1m',
      value: '1',
    },
  ],

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant