libere-tes-chaine-de-mots/search_app_ui/recuperer_reseaux.py

20 lines
674 B
Python
Raw Permalink Normal View History

2025-01-02 23:04:35 -05:00
import streamlit as st
from import_data.utils.typesense_client import client
def recuperer_reseaux():
search_parameters = {
'q': '*',
'query_by': 'network',
'facet_by': 'network',
'per_page': 0
}
try:
results = client.collections['social_media_posts'].documents.search(search_parameters)
networks = [facet['value'] for facet in results['facet_counts'][0]['counts']]
return networks
except Exception as e:
st.error(f"Erreur lors de la récupération des réseaux : {str(e)}")
return ['Facebook', 'Instagram', 'Threads', 'LinkedIn', 'WordPress'] # Valeurs par défaut en cas d'erreur