Use carpool events for metrics
All checks were successful
Amarillo/amarillo-gitea/amarillo-core/pipeline/head This commit looks good

This commit is contained in:
Csaba 2024-04-18 15:16:10 +02:00
parent 4d9b217dd2
commit 737f3f4a34
2 changed files with 0 additions and 22 deletions

View file

@ -95,12 +95,6 @@ async def _delete_carpool(agency_id: str, carpool_id: str):
logger.info(f"Saved carpool {agency_id}:{carpool_id} in trash.") logger.info(f"Saved carpool {agency_id}:{carpool_id} in trash.")
os.remove(f"data/carpool/{agency_id}/{carpool_id}.json") os.remove(f"data/carpool/{agency_id}/{carpool_id}.json")
try:
from amarillo.plugins.metrics import trips_deleted_counter
trips_deleted_counter.inc()
except ImportError:
pass
async def store_carpool(carpool: Carpool) -> Carpool: async def store_carpool(carpool: Carpool) -> Carpool:
carpool_exists = os.path.exists(f"data/carpool/{carpool.agency}/{carpool.id}.json") carpool_exists = os.path.exists(f"data/carpool/{carpool.agency}/{carpool.id}.json")
@ -108,17 +102,6 @@ async def store_carpool(carpool: Carpool) -> Carpool:
await set_lastUpdated_if_unset(carpool) await set_lastUpdated_if_unset(carpool)
await save_carpool(carpool) await save_carpool(carpool)
try:
from amarillo.plugins.metrics import trips_created_counter, trips_updated_counter
if(carpool_exists):
# logger.info("Incrementing trips updated")
trips_updated_counter.inc()
else:
# logger.info("Incrementing trips created")
trips_created_counter.inc()
except ImportError:
pass
return carpool return carpool
async def set_lastUpdated_if_unset(carpool): async def set_lastUpdated_if_unset(carpool):

View file

@ -37,11 +37,6 @@ class CarpoolService():
if cp and self.is_outdated(cp): if cp and self.is_outdated(cp):
logger.info("Purge outdated offer %s", key) logger.info("Purge outdated offer %s", key)
self.delete(cp.agency, cp.id) self.delete(cp.agency, cp.id)
try:
from amarillo.plugins.metrics import trips_deleted_counter
trips_deleted_counter.inc()
except ImportError:
pass
def get(self, agency_id: str, carpool_id: str): def get(self, agency_id: str, carpool_id: str):
return self.carpools.get(f"{agency_id}:{carpool_id}") return self.carpools.get(f"{agency_id}:{carpool_id}")