Query
Query
dataclass
¶
Class representing a query against the versioned datastore.
Source code in ckanext/query_dois/lib/query.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
authors
cached
property
¶
Given some resource ids, return a list of unique authors from the packages associated with them.
Returns:
| Type | Description |
|---|---|
List[str]
|
a list of authors |
count
cached
property
¶
The total number of records matching this query.
Returns:
| Type | Description |
|---|---|
int
|
an integer |
counts
cached
property
¶
Returns a dict containing the resource IDs as keys and the number of records which match this query in the resource as the values.
Returns:
| Type | Description |
|---|---|
Dict[str, int]
|
a dict of resource ids to counts |
query_hash
cached
property
¶
Returns:
| Type | Description |
|---|---|
str
|
a unique hash made from the query and query version |
resources_and_versions
cached
property
¶
Returns a dict containing the resource IDs as keys and their rounded versions as values. The rounded versions are acquired via the vds_version_round action.
Returns:
| Type | Description |
|---|---|
Dict[str, int]
|
a dict of resource IDs to rounded versions |
create(resource_ids, version=None, query=None, query_version=None)
classmethod
¶
Creates a Query object using the given parameters. The resource_ids are the only required parameters, everything else is optional and will be defaulted to sensible values if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource_ids
|
List[str]
|
the resource IDs |
required |
version
|
Optional[int]
|
the version to query at (if missing, defaults to now) |
None
|
query
|
Optional[dict]
|
the query to run (if missing, defaults to any empty query) |
None
|
query_version
|
Optional[str]
|
the version of the query (if missing, defaults to the latest query schema version) |
None
|
Returns:
| Type | Description |
|---|---|
Query
|
a Query object |
Source code in ckanext/query_dois/lib/query.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
create_from_download_request(download_request)
classmethod
¶
Given a download request from the vds, turn it into our representation of a query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
download_request
|
a DownloadRequest object from vds |
required |
Source code in ckanext/query_dois/lib/query.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
find_invalid_resources(resource_ids)
¶
Given a list of resource IDs, return a list of resource IDs which are invalid. Resources are invalid if they are any of the following:
- not datastore active resources (checked with vds_resource_check)
- not active
- not in an active package
- not in a public package
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource_ids
|
List[str]
|
the resource IDs to check |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
a list of resource IDs which failed the tests |
Source code in ckanext/query_dois/lib/query.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |