no update fechas
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -129,11 +129,11 @@ class MongoDBArticleCache:
|
||||
break
|
||||
|
||||
if user_info_index is not None:
|
||||
# Actualizar user_info existente
|
||||
# Actualizar user_info existente pero mantener notified_at original
|
||||
existing_user_info[user_info_index].update({
|
||||
'worker_name': worker_name or existing_user_info[user_info_index].get('worker_name'),
|
||||
'notified': True,
|
||||
'notified_at': datetime.utcnow(),
|
||||
# NO actualizar notified_at, mantener el valor existente
|
||||
# Mantener is_favorite existente
|
||||
'is_favorite': existing_user_info[user_info_index].get('is_favorite', False),
|
||||
})
|
||||
@@ -143,11 +143,24 @@ class MongoDBArticleCache:
|
||||
|
||||
article_data['user_info'] = existing_user_info
|
||||
|
||||
# Upsert: actualizar
|
||||
self._articles_collection.update_one(
|
||||
{'platform': article.get_platform(), 'id': str(article.get_id())},
|
||||
{'$set': article_data}
|
||||
)
|
||||
# Solo actualizar precio si es diferente, no actualizar fechas de notificación
|
||||
existing_price = existing.get('price')
|
||||
new_price = article.get_price()
|
||||
if existing_price == new_price:
|
||||
# Si el precio es el mismo, no actualizar el artículo
|
||||
# Solo actualizar user_info si cambió
|
||||
self._articles_collection.update_one(
|
||||
{'platform': article.get_platform(), 'id': str(article.get_id())},
|
||||
{'$set': {'user_info': existing_user_info}}
|
||||
)
|
||||
else:
|
||||
# Precio diferente, actualizar artículo completo
|
||||
# Mantener updatedAt para saber cuándo cambió el precio
|
||||
# pero NO actualizar notified_at (ya se mantiene arriba)
|
||||
self._articles_collection.update_one(
|
||||
{'platform': article.get_platform(), 'id': str(article.get_id())},
|
||||
{'$set': article_data}
|
||||
)
|
||||
else:
|
||||
# Artículo nuevo, crear con user_info
|
||||
article_data['user_info'] = [user_info_entry]
|
||||
@@ -216,11 +229,11 @@ class MongoDBArticleCache:
|
||||
break
|
||||
|
||||
if user_info_index is not None:
|
||||
# Actualizar user_info existente
|
||||
# Actualizar user_info existente pero mantener notified_at original
|
||||
existing_user_info[user_info_index].update({
|
||||
'worker_name': worker_name or existing_user_info[user_info_index].get('worker_name'),
|
||||
'notified': True,
|
||||
'notified_at': now,
|
||||
# NO actualizar notified_at, mantener el valor existente
|
||||
# Mantener is_favorite existente
|
||||
'is_favorite': existing_user_info[user_info_index].get('is_favorite', False),
|
||||
})
|
||||
@@ -234,14 +247,28 @@ class MongoDBArticleCache:
|
||||
'is_favorite': False,
|
||||
})
|
||||
|
||||
article_data['user_info'] = existing_user_info
|
||||
|
||||
operations.append(
|
||||
UpdateOne(
|
||||
{'platform': platform, 'id': article_id},
|
||||
{'$set': article_data}
|
||||
# Solo actualizar precio si es diferente, no actualizar fechas de notificación
|
||||
existing_price = existing.get('price')
|
||||
new_price = article.get_price()
|
||||
if existing_price == new_price:
|
||||
# Si el precio es el mismo, solo actualizar user_info
|
||||
operations.append(
|
||||
UpdateOne(
|
||||
{'platform': platform, 'id': article_id},
|
||||
{'$set': {'user_info': existing_user_info}}
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Precio diferente, actualizar artículo completo
|
||||
# Mantener updatedAt para saber cuándo cambió el precio
|
||||
# pero NO actualizar notified_at (ya se mantiene arriba)
|
||||
article_data['user_info'] = existing_user_info
|
||||
operations.append(
|
||||
UpdateOne(
|
||||
{'platform': platform, 'id': article_id},
|
||||
{'$set': article_data}
|
||||
)
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Artículo nuevo
|
||||
article_data['user_info'] = [{
|
||||
|
||||
Reference in New Issue
Block a user