Class: Telerivet::DataView
Overview
Represents a view of a data table, defined by a saved filter on the table's rows.
The view's filter conditions cannot be changed after the view is created (although the view can be renamed or deleted).
Telerivet will automatically store the count of rows matching each data view once a day, making it possible to retrieve historical statistics for the number of rows matching the filter.
Fields:
- id (string, max 34 characters)
* ID of the data view
* Read-only
- name
* Name of the data view
* Updatable via API
- num_rows (int)
* Number of rows matching the view filter. For performance reasons, this number may
sometimes be out-of-date.
* Read-only
- filters (Hash)
* Key-value pairs of conditions that rows must match to be included in the view, in
the same format as the `filters` parameter of
[table.createView](#DataTable.createView)
* Read-only
- table_id
* ID of the table this view belongs to
* Read-only
- project_id
* ID of the project this view belongs to
* Read-only
- url
* URL to this view in the Telerivet web app
* Read-only
Instance Method Summary collapse
-
#delete ⇒ Object
Permanently deletes the given view of a data table (does not delete any rows in the table).
- #filters ⇒ Object
- #get_base_api_path ⇒ Object
- #id ⇒ Object
- #name ⇒ Object
- #name=(value) ⇒ Object
- #num_rows ⇒ Object
- #project_id ⇒ Object
-
#query_rows(options = nil) ⇒ Object
Queries rows matching this view's filter conditions.
-
#save ⇒ Object
Saves any fields that have changed for this view.
- #table_id ⇒ Object
- #url ⇒ Object
Methods inherited from Entity
#get, #initialize, #load, #set, #set_data, #to_s, #vars
Constructor Details
This class inherits a constructor from Telerivet::Entity
Instance Method Details
#delete ⇒ Object
Permanently deletes the given view of a data table (does not delete any rows in the table)
90 91 92 |
# File 'lib/telerivet/dataview.rb', line 90 def delete() @api.do_request("DELETE", get_base_api_path()) end |
#filters ⇒ Object
110 111 112 |
# File 'lib/telerivet/dataview.rb', line 110 def filters get('filters') end |
#get_base_api_path ⇒ Object
126 127 128 |
# File 'lib/telerivet/dataview.rb', line 126 def get_base_api_path() "/projects/#{get('project_id')}/tables/#{get('table_id')}/views/#{get('id')}" end |
#id ⇒ Object
94 95 96 |
# File 'lib/telerivet/dataview.rb', line 94 def id get('id') end |
#name ⇒ Object
98 99 100 |
# File 'lib/telerivet/dataview.rb', line 98 def name get('name') end |
#name=(value) ⇒ Object
102 103 104 |
# File 'lib/telerivet/dataview.rb', line 102 def name=(value) set('name', value) end |
#num_rows ⇒ Object
106 107 108 |
# File 'lib/telerivet/dataview.rb', line 106 def num_rows get('num_rows') end |
#project_id ⇒ Object
118 119 120 |
# File 'lib/telerivet/dataview.rb', line 118 def project_id get('project_id') end |
#query_rows(options = nil) ⇒ Object
Queries rows matching this view's filter conditions.
Arguments:
- options (Hash)
- sort
* Sort the results based on a field
* Allowed values: default
* Default: default
- sort_dir
* Sort the results in ascending or descending order
* Allowed values: asc, desc
* Default: asc
- page_size (int)
* Number of results returned per page (max 500)
* Default: 50
- offset (int)
* Number of items to skip from beginning of result set
* Default: 0
Returns: Telerivet::APICursor (of Telerivet::DataRow)
75 76 77 78 |
# File 'lib/telerivet/dataview.rb', line 75 def query_rows( = nil) require_relative 'datarow' @api.cursor(DataRow, get_base_api_path() + "/rows", ) end |
#save ⇒ Object
Saves any fields that have changed for this view.
83 84 85 |
# File 'lib/telerivet/dataview.rb', line 83 def save() super end |
#table_id ⇒ Object
114 115 116 |
# File 'lib/telerivet/dataview.rb', line 114 def table_id get('table_id') end |
#url ⇒ Object
122 123 124 |
# File 'lib/telerivet/dataview.rb', line 122 def url get('url') end |