no update fechas
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -110,8 +110,8 @@ class MongoDBArticleCache:
|
||||
article_id = str(article.get_id())
|
||||
key = (platform, article_id)
|
||||
|
||||
# Preparar datos del artículo (sin user_info)
|
||||
article_data = {
|
||||
# Campos base del artículo (sin user_info, sin createdAt/updatedAt)
|
||||
base_fields = {
|
||||
'platform': platform,
|
||||
'id': article_id,
|
||||
'title': article.get_title(),
|
||||
@@ -124,7 +124,6 @@ class MongoDBArticleCache:
|
||||
'images': article.get_images(),
|
||||
'modified_at': article.get_modified_at(),
|
||||
'expiresAt': expires_at,
|
||||
'updatedAt': now,
|
||||
}
|
||||
|
||||
# Preparar user_info
|
||||
@@ -175,35 +174,37 @@ class MongoDBArticleCache:
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Precio diferente, actualizar artículo completo
|
||||
# Mantener updatedAt para saber cuándo cambió el precio
|
||||
# Eliminar notifiedAt/notified_at a nivel de artículo (solo debe estar en user_info)
|
||||
article_data['user_info'] = existing_user_info
|
||||
# Precio diferente, actualizar campos del artículo + user_info
|
||||
# Mantener createdAt/updatedAt originales (no se incluyen en el $set)
|
||||
update_data = dict(base_fields)
|
||||
update_data['user_info'] = existing_user_info
|
||||
operations.append(
|
||||
UpdateOne(
|
||||
{'platform': platform, 'id': article_id},
|
||||
{
|
||||
'$set': article_data,
|
||||
'$set': update_data,
|
||||
'$unset': {'notifiedAt': '', 'notified_at': ''}
|
||||
}
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Artículo nuevo
|
||||
article_data['user_info'] = [{
|
||||
new_article_data = dict(base_fields)
|
||||
new_article_data['user_info'] = [{
|
||||
'username': username,
|
||||
'worker_name': worker_name,
|
||||
'notified': True,
|
||||
'notified_at': now,
|
||||
'is_favorite': False,
|
||||
}]
|
||||
article_data['createdAt'] = now
|
||||
new_article_data['createdAt'] = now
|
||||
new_article_data['updatedAt'] = now
|
||||
|
||||
operations.append(
|
||||
UpdateOne(
|
||||
{'platform': platform, 'id': article_id},
|
||||
{
|
||||
'$set': article_data,
|
||||
'$set': new_article_data,
|
||||
},
|
||||
upsert=True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user