# LogDoctor: DbQuery Class Reference

Loading...
Searching...
No Matches
DbQuery Class Reference

## Public Member Functions

void | setDialogLevel (const int new_level)
| Returns the Dialogs level.
void | setDbPath (const std::string &path)
| Sets the path for the logs Collection database. More...
void | refreshDates (Result< stats_dates_t > &result)
| Refreshes the dates which are available in the database. More...
void | updateWarnings (const QString &web_server, const std::vector< std::tuple< int, int > > &updates) const
| Updates the database applying the changes made in the Warnings statistics table. More...
void | getWarnCounts (Result< stats_warn_items_t > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &hour_) const
| Retrieves the data needed for the Warnings statistics. More...
void | getSpeedData (Result< stats_speed_items_t > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &protocol_f, const QString &method_f, const QString &uri_f, const QString &query_f, const QString &response_f) const
| Retrieves the data needed for the Speed statistics. More...
void | getItemsCount (Result< stats_count_items_t > &result, const QString &web_server, const QString &year, const QString &month, const QString &day, const QString &log_field) const
| Retrieves the data needed for the Counts statistics. More...
void | getDaytimeCounts (Result< stats_day_items_t > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_, const QString &field_filter) const
| Retrieves the data needed for the Daytime statistics. More...
void | getRelationalCountsDay (Result< stats_relat_items_t > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2) const
| Retrieves the data needed for the Relationsl statistics. More...
void | getRelationalCountsPeriod (Result< stats_relat_items_t > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2) const
| Retrieves the data needed for the Relational statistics. More...

const bool

getGlobalCounts (const QString &web_server, const std::map< int, std::map< int, std::vector< int > > > &dates, std::vector< std::unordered_map< QString, unsigned > > &recurs, std::tuple< QString, int > &traf_date, std::unordered_map< int, double > &traf_day, std::unordered_map< int, double > &traf_hour, std::vector< long long > &perf_time, std::vector< long long > &perf_sent, std::vector< long long > &perf_receiv, long &req_count) const

| Retrieves the data needed for the Global statistics. More...

## Private Member Functions

const QString | getDbField (const QString &tr_fld) const
| Returns the database field corresponding to the relative log field. More...
const int | getMinuteGap (const int minute, const int gap=10) const
| Returns the minute gap for the given minute with the given gap. More...
const int | getMonthDays (const int year, const int month) const
| Returns the number of days for a given month. More...
const int | getMonthNumber (const QString &month_str) const
| Returns the month number in the year. More...
const int | countDays (const int from_year, const int from_month, const int from_day, const int to_year, const int to_month, const int to_day) const
| Returns the number of days in a given period. More...
const int | countMonths (const int &from_year, const int &from_month, const int &to_year, const int &to_month) const
| Returns the number of months in a given period. More...

## Member Function Documentation

## countDays()

const int DbQuery::countDays | ( | const int | from_year,
|  | const int | from_month,
|  | const int | from_day,
|  | const int | to_year,
|  | const int | to_month,
|  | const int | to_day
| ) |  | const

private

Returns the number of days in a given period.

Parameters

  from_year | The initial year
  from_month | The initial month
  from_day | The initial day
  to_year | The final Year
  to_month | The final month
  to_day | The final day

Returns
  The number of days

Exceptions

  DateTimeException |

## countMonths()

const int DbQuery::countMonths | ( | const int & | from_year,
|  | const int & | from_month,
|  | const int & | to_year,
|  | const int & | to_month
| ) |  | const

private

Returns the number of months in a given period.

Parameters

  from_year | The initial year
  from_month | The initial month
  to_year | The final Year
  to_month | The final month

Returns
  The number of months in the period

## getDaytimeCounts()

void DbQuery::getDaytimeCounts | ( | Result< stats_day_items_t > & | result,
|  | const QString & | web_server,
|  | const QString & | from_year_,
|  | const QString & | from_month_,
|  | const QString & | from_day_,
|  | const QString & | to_year_,
|  | const QString & | to_month_,
|  | const QString & | to_day_,
|  | const QString & | log_field_,
|  | const QString & | field_filter
| ) |  | const

Retrieves the data needed for the Daytime statistics.

Parameters

  result | Tuple which will hold the result of the operation and the data
  web_server | The ID of the Web Server to use
  from_year_ | The initial year
  from_month_ | The initial month
  from_day_ | The initial day
  to_year_ | The final year
  to_month_ | The final month
  to_day_ | The final day
  log_field_ | The log field to filter
  field_filter | The filter to apply

## getDbField()

const QString DbQuery::getDbField | ( | const QString & | tr_fld | ) | const

private

Returns the database field corresponding to the relative log field.

Parameters

  tr_fld | The log field, hendles translated text

Returns
  The database field

## getGlobalCounts()

const bool DbQuery::getGlobalCounts | ( | const QString & | web_server,
|  | const std::map< int, std::map< int, std::vector< int > > > & | dates,
|  | std::vector< std::unordered_map< QString, unsigned > > & | recurs,
|  | std::tuple< QString, int > & | traf_date,
|  | std::unordered_map< int, double > & | traf_day,
|  | std::unordered_map< int, double > & | traf_hour,
|  | std::vector< long long > & | perf_time,
|  | std::vector< long long > & | perf_sent,
|  | std::vector< long long > & | perf_receiv,
|  | long & | req_count
| ) |  | const

Retrieves the data needed for the Global statistics.

Parameters

  web_server | The ID of the Web Server to use
  dates | The dates to query
  recurs | Will hold the recurrencies of the items
  traf_date | Will hold the most trafficked date and the count
  traf_day | Will hold the most trafficked day of the week and the count
  traf_hour | Will hold the most trafficked hour of the day and the count
  perf_time | Will hold the overallo time taken
  perf_sent | Will hold the overall Bytes sent
  perf_receiv | Will hold the overall Bytes received
  req_count | Will hold the number of requests examined by the query

Returns
  Whether the operation has been successful or not

## getItemsCount()

void DbQuery::getItemsCount | ( | Result< stats_count_items_t > & | result,
|  | const QString & | web_server,
|  | const QString & | year,
|  | const QString & | month,
|  | const QString & | day,
|  | const QString & | log_field
| ) |  | const

Retrieves the data needed for the Counts statistics.

Parameters

  result | Tuple which will hold the result of the operation and the data
  web_server | The ID of the Web Server to use
  year | The year
  month | The month
  day | The day
  log_field | The log field

## getMinuteGap()

const int DbQuery::getMinuteGap | ( | const int | minute,
|  | const int | gap = `10`
| ) |  | const

private

Returns the minute gap for the given minute with the given gap.

Parameters

  minute | The minute of the hour
  gap | The gap used to split the hour

Returns
  The gap index

Exceptions

  DateTimeException |

## getMonthDays()

const int DbQuery::getMonthDays | ( | const int | year,
|  | const int | month
| ) |  | const

private

Returns the number of days for a given month.

Parameters

  year | The year, used to handle leap years
  month | The month

Returns
  The number of days

Exceptions

  DateTimeException |

## getMonthNumber()

const int DbQuery::getMonthNumber | ( | const QString & | month_str | ) | const

private

Returns the month number in the year.

Parameters

  month_str | The month

Returns
  The month number

## getRelationalCountsDay()

void DbQuery::getRelationalCountsDay | ( | Result< stats_relat_items_t > & | result,
|  | const QString & | web_server,
|  | const QString & | year_,
|  | const QString & | month_,
|  | const QString & | day_,
|  | const QString & | log_field_1_,
|  | const QString & | field_filter_1,
|  | const QString & | log_field_2_,
|  | const QString & | field_filter_2
| ) |  | const

Retrieves the data needed for the Relationsl statistics.

Used when querying a single day

Parameters

  result | Tuple which will hold the result of the operation and the data
  web_server | The ID of the Web Server to use
  year_ | The year
  month_ | The month
  day_ | The day
  log_field_1_ | The first log field to filter
  field_filter_1 | The filter to apply to the first field
  log_field_2_ | The second log field to filter
  field_filter_2 | The filter to apply to the second fiend

See also
  getRelationalCountsPeriod()

## getRelationalCountsPeriod()

void DbQuery::getRelationalCountsPeriod | ( | Result< stats_relat_items_t > & | result,
|  | const QString & | web_server,
|  | const QString & | from_year_,
|  | const QString & | from_month_,
|  | const QString & | from_day_,
|  | const QString & | to_year_,
|  | const QString & | to_month_,
|  | const QString & | to_day_,
|  | const QString & | log_field_1_,
|  | const QString & | field_filter_1,
|  | const QString & | log_field_2_,
|  | const QString & | field_filter_2
| ) |  | const

Retrieves the data needed for the Relational statistics.

Used when querying a period of time

Parameters

  result | Tuple which will hold the result of the operation and the data
  web_server | The ID of the Web Server to use
  from_year_ | The initial year
  from_month_ | The initial month
  from_day_ | The initial day
  to_year_ | The final year
  to_month_ | The final month
  to_day_ | The final day
  log_field_1_ | The first log field to filter
  field_filter_1 | The filter to apply to the first field
  log_field_2_ | The second log field to filter
  field_filter_2 | The filter to apply to the second fiend

See also
  getRelationalCountsDay()

## getSpeedData()

void DbQuery::getSpeedData | ( | Result< stats_speed_items_t > & | result,
|  | const QString & | web_server,
|  | const QString & | year_,
|  | const QString & | month_,
|  | const QString & | day_,
|  | const QString & | protocol_f,
|  | const QString & | method_f,
|  | const QString & | uri_f,
|  | const QString & | query_f,
|  | const QString & | response_f
| ) |  | const

Retrieves the data needed for the Speed statistics.

Parameters

  result | Tuple which will hold the result of the operation and the data
  web_server | The ID of the Web Server to use
  year_ | The year
  month_ | The month
  day_ | The day
  protocol_f | The filter for the Protocol field
  method_f | The filter for the Method field
  uri_f | The filter for the URI field
  query_f | The filter for the Query field
  response_f | The filter for the Response field

## getWarnCounts()

void DbQuery::getWarnCounts | ( | Result< stats_warn_items_t > & | result,
|  | const QString & | web_server,
|  | const QString & | year_,
|  | const QString & | month_,
|  | const QString & | day_,
|  | const QString & | hour_
| ) |  | const

Retrieves the data needed for the Warnings statistics.

Parameters

  result | Tuple which will hold the result of the operation and the data
  web_server | The ID of the Web Server to use
  year_ | The year
  month_ | The month
  day_ | The day
  hour_ | The hour

## refreshDates()

void DbQuery::refreshDates | ( | Result< stats_dates_t > & | result | ) |

Refreshes the dates which are available in the database.

Parameters

  result | Tuple which will hold the result of the operation and the data

## setDbPath()

void DbQuery::setDbPath | ( | const std::string & | path | ) |

Sets the path for the logs Collection database.

See also
  Crapview::setDbPath()

## updateWarnings()

void DbQuery::updateWarnings | ( | const QString & | web_server,
|  | const std::vector< std::tuple< int, int > > & | updates
| ) |  | const

Updates the database applying the changes made in the Warnings statistics table.

Parameters

  web_server | The ID of the Web Server to use
  updates | The list of rowids to update and the corresponding warning values

The documentation for this class was generated from the following files:

- logdoctor/modules/crapview/modules/query.h
- logdoctor/modules/crapview/modules/query.cpp