Skip to content

Commit

Permalink
Updates 2024-10-04 - Improved explorer class and added in dataframe m…
Browse files Browse the repository at this point in the history
…ethod for current package endpoint
  • Loading branch information
CHRISCARLON committed Oct 4, 2024
1 parent 0b1f276 commit ae1fdf3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions HerdingCats/explorer/cat_explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,15 @@ def package_list_dataframe_extra(
# ----------------------------
def catalogue_freshness(self):
"""
Explore all packages that are available to query.
Returns a view of how many resources have been updated in the last 6 months
as a percentage of the total number of resources, based on unique package names.
This might not work for all catalogues.
It currently uses metadata_modified at the dataset level - not resource level.
"""
logger.warning(
"This method might not work for all catalogues, and will return 0s"
"This method might not work for all catalogues, and will return 0s. It currently only works for the London Datastore."
)

url = (
Expand Down Expand Up @@ -429,9 +432,9 @@ def catalogue_freshness(self):
# ----------------------------
def package_show_info_json(self, package_name: Union[str, dict, Any]) -> List[Dict]:
"""
Pass in a package name as a string or as a value from a dictionary
Pass in a package name as a string or as a value from a dictionary.
This will return package metadata including resource information and download links for the data
This will return package metadata including resource information and download links for the data.
# Example usage...
if __name__ == "__main__":
Expand Down Expand Up @@ -467,15 +470,14 @@ def package_show_info_json(self, package_name: Union[str, dict, Any]) -> List[Di
raise CatExplorerError(f"Failed to search datasets: {str(e)}")

# ----------------------------
# Search Packages and store in DataFrames / or keep as Dicts
# Unpack data or keep it packed (e.g. don't split out resources into own columns')
# Search Packages and store in DataFrames / or keep as Dicts.
# Unpack data or keep it packed (e.g. don't split out resources into own columns)
# ----------------------------
def package_search_json(self, search_query: str, num_rows: int):
"""
Returns all available data for a particular search query
Specify the number of rows if the 'count' is large
"""

base_url = self.cat_session.base_url + CkanApiPaths.PACKAGE_SEARCH
Expand Down

0 comments on commit ae1fdf3

Please sign in to comment.