bigquery_view_service
class bigquery_view_service
A service class for managing Google BigQuery views and database tables within Moodle.
This class provides methods for handling default and custom views, managing database table configurations, and integrating with plugins that register additional views. It also manages the interactions related to enabling and disabling specific database tables for use within the BigQuery service.
Constants
| MODE_ONLY_DEFAULT |
|
| MODE_DEFAULT_AND_CUSTOM |
|
| MODE_CUSTOM_AND_DEFAULT |
|
| MODE_ONLY_CUSTOM |
|
Methods
Retrieves a list of views based on configuration and mode settings.
Retrieves a list of generic default views.
Retrieves all the table names from the Moodle database.
Retrieves an array of database table information, including table metadata, active status, default status, and other relevant details.
Saves the state of a database table to the configuration.
Executes a test on the Google BigQuery API service and processes the results.
Retrieves available modes as options or a specific mode label based on the input.
Cleans up files associated with Google BigQuery jobs that have not been marked as deleted.
Filters and retrieves the default view data based on a specific criteria.
Retrieves and organizes data for list views including default and custom views.
Filters and retrieves custom view data based on specific criteria.
Retrieves the full name of a Google BigQuery view based on the given ID.
Retrieves the row count for a specified table from the Google BigQuery configuration.
Details
at line 54
static array|false
get_views()
Retrieves a list of views based on configuration and mode settings.
This method generates a collection of views, which may include default views, custom views, or a combination, depending on the mode and enabled tables specified in the configuration settings.
at line 121
static array
get_generic_default_views()
Retrieves a list of generic default views.
at line 170
static array
get_all_moodle_table()
Retrieves all the table names from the Moodle database.
at line 186
static array
get_db_table()
Retrieves an array of database table information, including table metadata, active status, default status, and other relevant details.
at line 228
static bool
save_db_table(object $table)
Saves the state of a database table to the configuration.
at line 268
static array|string
formatted_test()
Executes a test on the Google BigQuery API service and processes the results.
This method attempts to run a test using the Google BigQuery API service. If the test result is an array, it renders and returns the output using a specific template. If the test result is an Exception, it returns an error message. If an error occurs during the execution, the exception message is captured and returned.
at line 300
static array|string
get_options_modes(bool|int $mode = false)
Retrieves available modes as options or a specific mode label based on the input.
This method generates an array of modes with their corresponding labels. If a specific mode is provided as input, it returns the label for that particular mode. Otherwise, it returns the full list of mode options.
at line 331
static void
file_cleanup()
Cleans up files associated with Google BigQuery jobs that have not been marked as deleted.
This method iterates through all Google BigQuery views and retrieves associated job items that have not been marked as deleted (i.e., where 'file_deleted_at' is NULL). It processes these items in batches, calling the cleanup method on each item to perform necessary cleanup operations based on the current time and configuration settings.
The method uses pagination to handle large datasets, processing a specified number of items per page. It logs progress messages to indicate the start and completion of the cleanup process for each view and item.
at line 383
static array
get_default_view_data(array $data)
Filters and retrieves the default view data based on a specific criteria.
This method processes the input data, filtering out items whose 'idnumber' does not start with 'default_'. It then re-indexes the filtered array to ensure a contiguous numeric index.
at line 401
static array
get_list_view_data()
Retrieves and organizes data for list views including default and custom views.
This method interacts with the Google BigQuery views, fetching all available views and formatting their details into an array. The data is then categorized into default views and custom views for further usage.
at line 438
static array
get_custom_view_data(array $data)
Filters and retrieves custom view data based on specific criteria.
This method filters the provided data array to include only the items where the 'idnumber' starts with the specified prefix 'custom_'. The filtered data is then re-indexed and returned.
at line 452
static string
get_view_fullname(mixed $id)
Retrieves the full name of a Google BigQuery view based on the given ID.
at line 466
static int
get_table_count_rows(string $table)
Retrieves the row count for a specified table from the Google BigQuery configuration.