Skip to content

Commit

Permalink
remove elasticsearch api and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Nov 28, 2024
1 parent 0bb98f6 commit 6423662
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 1,209 deletions.
11 changes: 0 additions & 11 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,14 +955,3 @@
OPENAI_API_BASE = env.str("OPENAI_API_BASE", "")
OPENAI_API_KEY = env.str("OPENAI_API_KEY", "")
OPENAI_MODEL = env.str("OPENAI_MODEL", "")


# ELASTICSEARCH
# ------------------------------------------------------------------------------
ELASTICSEARCH_SCHEME = env.str("ELASTICSEARCH_SCHEME", "https")
ELASTICSEARCH_HOST = env.str("ELASTICSEARCH_HOST", "")
ELASTICSEARCH_PORT = env.str("ELASTICSEARCH_PORT", "443")
ELASTICSEARCH_USERNAME = env.str("ELASTICSEARCH_USERNAME", "")
ELASTICSEARCH_PASSWORD = env.str("ELASTICSEARCH_PASSWORD", "")
ELASTICSEARCH_INDEX_SIAES = env.str("ELASTICSEARCH_INDEX_SIAES", "")
ELASTICSEARCH_MIN_SCORE = env.float("ELASTICSEARCH_MIN_SCORE", 0.9)
7 changes: 0 additions & 7 deletions env.default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,3 @@ export OPENAI_API_BASE=""
export OPENAI_API_KEY=""
export OPENAI_MODEL=""

# ELASTICSEARCH
# ########################
export ELASTICSEARCH_HOST=
export ELASTICSEARCH_USERNAME=
export ELASTICSEARCH_PASSWORD=
export ELASTICSEARCH_INDEX_SIAES=
export ELASTICSEARCH_MIN_SCORE=

This file was deleted.

35 changes: 0 additions & 35 deletions lemarche/siaes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,41 +1192,6 @@ def latest_activity_at(self):
latest_activity_at = self.updated_at
return latest_activity_at

@property
def elasticsearch_index_text(self):
text = self.description
if self.offers.count() > 0:
offers = "\n\nPrestations:\n"
for offer in self.offers.all():
offers += f"- {offer.name}:\n{offer.description}\n\n"
text += offers
return text

@property
def elasticsearch_index_metadata(self):
metadata = {
"id": self.id,
"name": self.name,
"website": self.website if self.website else "",
"kind": self.kind,
}
if self.latitude and self.longitude:
metadata["geo_location"] = {
"lat": self.latitude,
"lon": self.longitude,
}

if self.geo_range == siae_constants.GEO_RANGE_COUNTRY:
metadata["geo_country"] = True
elif self.geo_range == siae_constants.GEO_RANGE_REGION:
metadata["geo_reg"] = self.region
elif self.geo_range == siae_constants.GEO_RANGE_DEPARTMENT:
metadata["geo_dep"] = self.department
elif self.geo_range == siae_constants.GEO_RANGE_CUSTOM:
metadata["geo_dist"] = self.geo_range_custom_distance

return metadata

def sectors_list_string(self, display_max=3):
sectors_name_list = self.sectors.form_filter_queryset().values_list("name", flat=True)
if display_max and len(sectors_name_list) > display_max:
Expand Down
4 changes: 0 additions & 4 deletions lemarche/static/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ window.addEventListener('DOMContentLoaded', function () {

initModalMessages();

// reload click events and tooltip after htmx content loading as in semantic search
document.addEventListener('htmx:afterSwap', function (event) {
initSuperBadges();
});
initSuperBadges();

// some elements have their url in data-url attribute
Expand Down
29 changes: 11 additions & 18 deletions lemarche/tenders/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# import datetime
from datetime import timedelta
from importlib import import_module
from random import randint
from unittest import mock

from django.apps import apps
from django.contrib.gis.geos import Point
Expand Down Expand Up @@ -218,22 +216,17 @@ def setUpTestData(cls):
cls.siae_five = SiaeFactory()

def test_set_siae_found_list(self):
with mock.patch(
"lemarche.tenders.models.api_elasticsearch.siaes_similarity_search"
) as mock_siaes_similarity_search:
tender = TenderFactory(
presta_type=[siae_constants.PRESTA_BUILD],
sectors=[self.sector],
is_country_area=True,
validated_at=None,
)

siaes_found = Siae.objects.filter_with_tender_through_activities(tender)
tender.set_siae_found_list()
tender.refresh_from_db()
self.assertEqual(list(siaes_found), list(tender.siaes.all()))

mock_siaes_similarity_search.assert_not_called()
tender = TenderFactory(
presta_type=[siae_constants.PRESTA_BUILD],
sectors=[self.sector],
is_country_area=True,
validated_at=None,
)

siaes_found = Siae.objects.filter_with_tender_through_activities(tender)
tender.set_siae_found_list()
tender.refresh_from_db()
self.assertEqual(list(siaes_found), list(tender.siaes.all()))


class TenderModelQuerysetTest(TestCase):
Expand Down
107 changes: 0 additions & 107 deletions lemarche/utils/apis/api_elasticsearch.py

This file was deleted.

Loading

0 comments on commit 6423662

Please sign in to comment.