Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Impossible de déplacer un sujet qui vient d'être créé #6681

Open
Situphen opened this issue Oct 30, 2024 · 0 comments · May be fixed by #6709
Open

Impossible de déplacer un sujet qui vient d'être créé #6681

Situphen opened this issue Oct 30, 2024 · 0 comments · May be fixed by #6709
Labels
C-Back Concerne le back-end Django C-Search Concerne la recherche (et Typesense) S-BUG Corrige un problème

Comments

@Situphen
Copy link
Member

Lorsqu'on essaie de déplacer un sujet qui vient d'être créé, on a une erreur interne. La cause est simple à comprendre : on essaie de désindexer le sujet alors qu'il n'a pas encore été indexé en base de données !

Cela pourrait être traité dans la fonction Post.save au niveau de ce bloc de code :

if is_moved and self.forum.groups is not None:
# Moved to a restricted forum, we remove it from the search
# engine, will be correctly reindexed later (this approach is
# simpler than updating everything in the search engine)
search_engine_manager = SearchIndexManager()
filter_by = SearchFilter()
filter_by.add_exact_filter("topic_pk", [self.pk])
search_engine_manager.delete_by_query(Post.get_search_document_type(), {"filter_by": str(filter_by)})
search_engine_manager.delete_document(self)

Ou alors, et c'est probablement une solution plus pérenne, directement dans la fonction search_engine_manager.delete_document qui est la source de l'erreur :

def delete_document(self, document):
"""Delete a given document
:param document: the document to delete
:type document: AbstractSearchIndexable
"""
if not self.connected:
return
doc_type = document.get_search_document_type()
doc_id = document.search_engine_id
if doc_id is None or doc_type not in self.collections:
# This condition is here especially for tests
return
answer = self.engine.collections[doc_type].documents[doc_id].delete()
if "id" not in answer or answer["id"] != doc_id:
self.logger.warn(f"Error when deleting: {answer}.")

@Situphen Situphen added S-BUG Corrige un problème C-Back Concerne le back-end Django labels Oct 30, 2024
@Situphen Situphen moved this from À trier to À traiter in Suivi des tickets Oct 30, 2024
@philippemilink philippemilink added the C-Search Concerne la recherche (et Typesense) label Nov 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-Back Concerne le back-end Django C-Search Concerne la recherche (et Typesense) S-BUG Corrige un problème
Projects
Status: À traiter
Development

Successfully merging a pull request may close this issue.

2 participants