Hello,
i’m new to django framework, and i’m building a search engine bot based on NLP & machine learning,
everyting i made is working but i have issues with the response is too slow, and i don’t know why
Here is my code
class SemanticViewSet(APIView):
def post(self, request, format=None):
return Response(ResponseBuilder.build(request.data))
class ResponseBuilder:
@staticmethod
def build( requestParams ):
params = {
"start-date" : requestParams.get("startDate"),
"end-date" : requestParams.get("endDate"),
"category" : requestParams.get("category"),
"keyword" : requestParams.get("keyword"),
"sort" : requestParams.get("sort"),
"author" : requestParams.get("author"),
"text" : requestParams.get("text"),
"dataType" : requestParams.get("dataType"),
}
fetchedData = {}
requestQuery = {
'params' : params
}
if params["dataType"] == "article":
requestQuery["query"] = {
"articles" : ConcreteDataListProvider.getArticles()
}
fetchedData["articles"] = ArticleRepository.fetch(requestQuery)
elif params["dataType"] == "journal":
requestQuery["query"] = {
"newspapers" : ConcreteDataListProvider.getNewspapers(),
"articles" : ConcreteDataListProvider.getArticles(),
}
fetchedData["newspapers"] = NewspaperRepository.fetch(requestQuery)
elif params["dataType"] == "0":
requestQuery["query"] = {
"newspapers" : ConcreteDataListProvider.getNewspapers(),
"articles" : ConcreteDataListProvider.getArticles(),
}
fetchedData["newspapers"] = NewspaperRepository.fetch(requestQuery)
fetchedData["articles"] = ArticleRepository.fetch({
'query' : requestQuery["query"],
'params' : params
})
if "text" in params and params["text"] != "":
fetchedData["semantic"] = SemanticDataExtactor.gatherDataFromModels({
"query" : requestQuery["query"],
"termToSearch" : params["text"]
})
fetchedData["params"] = params
fetchedSemanticData = SemanticDataExtactor.arrangeData(fetchedData)
if len(fetchedSemanticData) > 0:
fetchedData = fetchedSemanticData
return DataDecorator.mergeData(fetchedData)