diff --git a/sde_collections/admin.py b/sde_collections/admin.py index 639802b7..582e5758 100644 --- a/sde_collections/admin.py +++ b/sde_collections/admin.py @@ -77,6 +77,7 @@ def import_sinequa_metadata(modeladmin, request, queryset): for collection in queryset.all(): # eventually this needs to be done in celery collection.import_metadata_from_sinequa_config() + collection_names = ", ".join(queryset.values_list("name", flat=True)) messages.add_message( request, messages.INFO, diff --git a/sde_collections/sinequa_api.py b/sde_collections/sinequa_api.py index 749dfe2e..eb5d19de 100644 --- a/sde_collections/sinequa_api.py +++ b/sde_collections/sinequa_api.py @@ -124,5 +124,31 @@ def sql_query(self, sql: str) -> Any: raise Exception(f"API request failed: {str(e)}") def get_full_texts(self, collection_config_folder: str) -> Any: + ''' + Retrieves the full texts, URLs, and titles for a specified collection. + + Returns: + dict: A JSON response containing the results of the SQL query in an expected format under the 'Rows' key, + where each item has 'url1', 'text', and 'title' . + + Example: + Calling get_full_texts("example_collection") might return: + { + 'Rows': [ + { + 'url1': 'http://example.com/article1', + 'text': 'Here is the full text of the first article...', + 'title': 'Article One Title' + }, + { + 'url1': 'http://example.com/article2', + 'text': 'Here is the full text of the second article...', + 'title': 'Article Two Title' + } + ] + } + + ''' sql = f"SELECT url1, text, title FROM sde_index WHERE collection = '/SDE/{collection_config_folder}/'" return self.sql_query(sql) + \ No newline at end of file