Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
02574c4
[fix] fix #1834 : durations filter wasn't working
Dec 4, 2025
e798b04
[improve] add range filter to reduce time of computation
Dec 4, 2025
78809dd
[fix] fix title query for waypoints in Iitnévert
Dec 5, 2025
dacb3ee
[fix] fix langs filter not working
Dec 8, 2025
3129ac4
[fix] fixed incorrect join with area association
Dec 8, 2025
fec12b3
[fix] fix title filter when no other filters
Dec 8, 2025
19c2da4
[fix] fix lang filter
Dec 9, 2025
468136c
[clean] remove debug log
Dec 10, 2025
fb23ddd
[new feature] add job handling for journey queries to monitor their p…
Dec 10, 2025
adaeebd
[lint] fix linter -> func names in lower case
Dec 10, 2025
dbb7763
Merge branch 'gp/Recette'
Dec 10, 2025
af30a28
[fix] fix search doc missing for coverage
Dec 10, 2025
029bd4b
[CI] set -xe in script
lgourdin Dec 12, 2025
f38b991
[refactor] Use of Elastic Search filters in reachable routes instead …
Dec 15, 2025
3bb3318
[fix] fix sort + when no results found
Dec 17, 2025
7d3e912
[lint] fix flake8 linter
Dec 18, 2025
249f7ae
Merge branch 'main' of https://git.smart-origin.com/SmartOrigin/c2c_v…
Dec 18, 2025
4abff59
Merge branch 'gp/refactor'
Dec 18, 2025
023db80
[fix] fix too restrictive offset and limit for navitia reachable docs
Jan 6, 2026
c922e2d
[improve] return error id when 404 for navitia/journeys route
Jan 9, 2026
5880724
[clean] fix noqa, translate french comms to english, remove use of f …
Jan 12, 2026
649fbdf
Merge branch 'gp/recette3'
Jan 12, 2026
260c375
[doc] update SO README
lgourdin Jan 13, 2026
ce567e8
[fix] fix codacy issues
Jan 16, 2026
a3f3f8c
[clean] remove unused route
Jan 22, 2026
ec6e6ba
[fix] fix update_navitia_coverage script for prod usage
Jan 22, 2026
8b855f4
Merge branch 'gp/recette4'
Jan 22, 2026
3f2d576
[clean] fix unused variable
Jan 22, 2026
eee337f
[clean] remove useless parameters
Jan 26, 2026
226957b
[doc] add coverage doc
Jan 26, 2026
7bca72f
[clean] remove useless class
Jan 26, 2026
64ecacf
[refactor] use of BASE_URL constant for navitia api
Jan 26, 2026
80e4b57
[clean] remove archive coverage class as coverages are not meant to b…
Jan 26, 2026
d210b92
[doc] update S/O readme
Jan 26, 2026
f591613
[fix] fix coverage insert (no archive class)
Jan 28, 2026
899a7a1
[fix] fix update_navitia_coverage script deletion part
Jan 28, 2026
fc431ad
[fix] fix chunks size being above ES max result window
Jan 29, 2026
ebd713d
[fix] add a constant chunk_size instead to prevent circular import wi…
Jan 29, 2026
d5e56fd
Merge branch 'master' into lg/refactor_cd
lgourdin Feb 13, 2026
3cfdb14
[docker] gunicorn worker timeout
lgourdin Mar 9, 2026
1a947c2
[env] default image backend not working
lgourdin Mar 9, 2026
b6980e3
[CI] fstrings in navitia url generation for waypoints
lgourdin Mar 9, 2026
e32ed40
[scripts][es] add create_index script
lgourdin Mar 9, 2026
0a2b3e6
[SQUASH][GP][improve] replace chunk size by ES_MAX_RESULT_WINDOW con…
lgourdin Mar 9, 2026
510afbe
[SQUASH][GP][improve] add a default case for trip duration
lgourdin Mar 9, 2026
107bc34
[chore] cleanup s/o config
lgourdin Mar 9, 2026
11c0da4
[env] remove comment and broken link
lgourdin Mar 16, 2026
711f21a
[scripts] fill_index: add main hook
lgourdin Mar 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions c2corg_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def process_new_waypoint(mapper, connection, geometry):
stop_id = place["id"]

# Get informations of stopareas to know its transports
stop_info_url = "https://api.navitia.io/v1/places/%d", stop_id
stop_info_url = f"https://api.navitia.io/v1/places/{stop_id}"
stop_info_response = requests.get(
stop_info_url, headers=navitia_headers
)
Expand Down Expand Up @@ -619,8 +619,12 @@ def _update_route_duration(connection, route_id, calculated_duration_in_days):
),
{"duration": calculated_duration_in_days, "route_id": route_id},
)
if (calculated_duration_in_days is None):
calculated_duration_in_days_str = "None"
else:
calculated_duration_in_days_str = "%f", calculated_duration_in_days
log.info(
"Route %d: Database updated with calculated_duration = %f days.",
"Route %d: Database updated with calculated_duration = %s days.",
route_id,
calculated_duration_in_days
calculated_duration_in_days_str
)
61 changes: 61 additions & 0 deletions c2corg_api/scripts/es/create_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python
"""
Creates (or recreates) the ES index with the correct mappings.
Must be run before fill_index.py when building the index from scratch.

Usage: python create_index.py <config>.ini
"""
import sys
import logging

from pyramid.paster import get_appsettings, setup_logging
from pyramid.scripts.common import parse_vars

from c2corg_api.search import configure_es_from_config, elasticsearch_config, \
search_documents
from c2corg_api.search.mapping import analysis_settings


def main(argv=sys.argv):
if len(argv) < 2:
print('Usage: %s <config_uri> [var=value]' % argv[0])
sys.exit(1)

config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
logging.getLogger('sqlalchemy.engine').setLevel(logging.ERROR)

settings = get_appsettings(config_uri, options=options)
configure_es_from_config(settings)

client = elasticsearch_config['client']
index_name = elasticsearch_config['index']

# Delete index if it exists (to fix potentially wrong mappings)
if client.indices.exists(index=index_name):
print('Deleting existing index: {}'.format(index_name))
client.indices.delete(index=index_name)

# Create index with analysis settings
print('Creating index: {}'.format(index_name))
client.indices.create(index=index_name, body={
'settings': {
'analysis': analysis_settings
}
})

# Apply the correct mapping for every document type
# (if we let ES infer types by directly running fill_index.py,
# we could run into type errors on some fields like
# a mapping geom -> double instead of geo_point).
for doc_type, search_class in search_documents.items():
print('Applying mapping for doc_type: {}'.format(doc_type))
search_class._doc_type.mapping.save(index_name)

print('Done. Index "{}" created with correct mappings.'.format(index_name))
print('You can now run fill_index.py safely.')


if __name__ == '__main__':
main()
3 changes: 3 additions & 0 deletions c2corg_api/scripts/es/fill_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,6 @@ def progress(count, total_count):

duration = datetime.now() - status['start_time']
print('Done (duration: {0})'.format(duration))

if __name__ == '__main__':
main()
9 changes: 3 additions & 6 deletions c2corg_api/search/advanced_search.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from c2corg_api.search.mapping_types import meta_param_keys
from c2corg_api.search.search_filters import build_query

# the chunk size for each elastic search request
# should be <= ES_MAX_RESULT_WINDOW
CHUNK_SIZE = 10000


def get_search_documents(url_params, meta_params, doc_type):
"""Returns a function that when called with a base-query returns all
Expand Down Expand Up @@ -89,13 +85,14 @@ def get_all_filtered_docs(


def chunk_ids(ids_set):
from c2corg_api.views.document import ES_MAX_RESULT_WINDOW
"""
Yield successive chunks of IDs from a set/list.
chunk size is ES_MAX_RESULT_WINDOW
"""
ids_list = list(ids_set)
for i in range(0, len(ids_list), CHUNK_SIZE):
yield ids_list[i:i + CHUNK_SIZE]
for i in range(0, len(ids_list), ES_MAX_RESULT_WINDOW):
yield ids_list[i:i + ES_MAX_RESULT_WINDOW]


def contains_search_params(url_params):
Expand Down
8 changes: 6 additions & 2 deletions c2corg_api/views/navitia.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,9 @@ def extract_isochrone_params(request):
),
MIN_TRIP_DURATION * 60
)
else:
# default is max trip duration
params['boundary_duration[]'] = MAX_TRIP_DURATION * 60
return params


Expand Down Expand Up @@ -766,8 +769,9 @@ def handle_navitia_response(response):
response.json().get("error", {}))

elif not response.ok:
raise HTTPInternalServerError("Navitia API error: %d ",
response.status_code)
raise HTTPInternalServerError(
"Navitia API error: %d " % response.status_code
)

return response.json()

Expand Down
2 changes: 1 addition & 1 deletion config/env.default
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ redis_cache_key_prefix="c2corg_${instanceid}"
redis_cache_status_refresh_period=30

image_backend_url="http://images.demov6.camptocamp.org"
image_url="https://sos.exo.io/c2corg_demov6_active/"
image_url="https://media.camptocamp.org/c2corg-active"

discourse_url="https://forum.demov6.camptocamp.org"
discourse_public_url="https://forum.demov6.camptocamp.org"
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ RUN chown -R root:root /var/www \
EXPOSE 8080
ENTRYPOINT ["./docker/scripts/entrypoint.sh"]

CMD ["gunicorn", "--paste", "production.ini", "-u", "www-data", "-g", "www-data", "-b", ":8080"]
CMD ["gunicorn", "--paste", "production.ini", "-u", "www-data", "-g", "www-data", "-b", ":8080", "--timeout", "120"]
Loading