no update fechas
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -41,7 +41,6 @@ services:
|
|||||||
# Montar archivos de configuración y datos en ubicación predecible
|
# Montar archivos de configuración y datos en ubicación predecible
|
||||||
- ./config.yaml:/data/config.yaml:ro
|
- ./config.yaml:/data/config.yaml:ro
|
||||||
- ./logs:/data/logs:rw
|
- ./logs:/data/logs:rw
|
||||||
# Montar el directorio raíz para acceso a archivos
|
|
||||||
- .:/data/project:ro
|
- .:/data/project:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
mongodb:
|
mongodb:
|
||||||
@@ -89,7 +88,6 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
# Montar archivos de configuración
|
# Montar archivos de configuración
|
||||||
- ./config.yaml:/app/config.yaml:ro
|
- ./config.yaml:/app/config.yaml:ro
|
||||||
# Montar directorio de logs en lugar del archivo para evitar problemas
|
|
||||||
- ./logs:/app/logs:rw
|
- ./logs:/app/logs:rw
|
||||||
depends_on:
|
depends_on:
|
||||||
mongodb:
|
mongodb:
|
||||||
|
|||||||
@@ -129,11 +129,11 @@ class MongoDBArticleCache:
|
|||||||
break
|
break
|
||||||
|
|
||||||
if user_info_index is not None:
|
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({
|
existing_user_info[user_info_index].update({
|
||||||
'worker_name': worker_name or existing_user_info[user_info_index].get('worker_name'),
|
'worker_name': worker_name or existing_user_info[user_info_index].get('worker_name'),
|
||||||
'notified': True,
|
'notified': True,
|
||||||
'notified_at': datetime.utcnow(),
|
# NO actualizar notified_at, mantener el valor existente
|
||||||
# Mantener is_favorite existente
|
# Mantener is_favorite existente
|
||||||
'is_favorite': existing_user_info[user_info_index].get('is_favorite', False),
|
'is_favorite': existing_user_info[user_info_index].get('is_favorite', False),
|
||||||
})
|
})
|
||||||
@@ -143,7 +143,20 @@ class MongoDBArticleCache:
|
|||||||
|
|
||||||
article_data['user_info'] = existing_user_info
|
article_data['user_info'] = existing_user_info
|
||||||
|
|
||||||
# Upsert: actualizar
|
# 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(
|
self._articles_collection.update_one(
|
||||||
{'platform': article.get_platform(), 'id': str(article.get_id())},
|
{'platform': article.get_platform(), 'id': str(article.get_id())},
|
||||||
{'$set': article_data}
|
{'$set': article_data}
|
||||||
@@ -216,11 +229,11 @@ class MongoDBArticleCache:
|
|||||||
break
|
break
|
||||||
|
|
||||||
if user_info_index is not None:
|
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({
|
existing_user_info[user_info_index].update({
|
||||||
'worker_name': worker_name or existing_user_info[user_info_index].get('worker_name'),
|
'worker_name': worker_name or existing_user_info[user_info_index].get('worker_name'),
|
||||||
'notified': True,
|
'notified': True,
|
||||||
'notified_at': now,
|
# NO actualizar notified_at, mantener el valor existente
|
||||||
# Mantener is_favorite existente
|
# Mantener is_favorite existente
|
||||||
'is_favorite': existing_user_info[user_info_index].get('is_favorite', False),
|
'is_favorite': existing_user_info[user_info_index].get('is_favorite', False),
|
||||||
})
|
})
|
||||||
@@ -234,8 +247,22 @@ class MongoDBArticleCache:
|
|||||||
'is_favorite': False,
|
'is_favorite': False,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# 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
|
article_data['user_info'] = existing_user_info
|
||||||
|
|
||||||
operations.append(
|
operations.append(
|
||||||
UpdateOne(
|
UpdateOne(
|
||||||
{'platform': platform, 'id': article_id},
|
{'platform': platform, 'id': article_id},
|
||||||
|
|||||||
@@ -744,18 +744,35 @@ export async function saveArticle(articleData) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (existingUserInfoIndex >= 0) {
|
if (existingUserInfoIndex >= 0) {
|
||||||
// Actualizar user_info existente
|
// Actualizar user_info existente pero mantener notified_at original
|
||||||
existingUserInfo[existingUserInfoIndex] = {
|
existingUserInfo[existingUserInfoIndex] = {
|
||||||
...existingUserInfo[existingUserInfoIndex],
|
...existingUserInfo[existingUserInfoIndex],
|
||||||
worker_name: worker_name || existingUserInfo[existingUserInfoIndex].worker_name,
|
worker_name: worker_name || existingUserInfo[existingUserInfoIndex].worker_name,
|
||||||
notified: true,
|
notified: true,
|
||||||
notified_at: new Date(),
|
// NO actualizar notified_at, mantener el valor existente
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Añadir nuevo user_info
|
// Añadir nuevo user_info
|
||||||
existingUserInfo.push(userInfoEntry);
|
existingUserInfo.push(userInfoEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Solo actualizar precio si es diferente, no actualizar fechas de notificación
|
||||||
|
const existingPrice = existing.price;
|
||||||
|
const newPrice = articleFields.price;
|
||||||
|
if (existingPrice === newPrice) {
|
||||||
|
// Si el precio es el mismo, solo actualizar user_info
|
||||||
|
await articlesCollection.updateOne(
|
||||||
|
{ platform, id },
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
user_info: existingUserInfo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} 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)
|
||||||
await articlesCollection.updateOne(
|
await articlesCollection.updateOne(
|
||||||
{ platform, id },
|
{ platform, id },
|
||||||
{
|
{
|
||||||
@@ -767,6 +784,7 @@ export async function saveArticle(articleData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Artículo nuevo, crear con user_info
|
// Artículo nuevo, crear con user_info
|
||||||
await articlesCollection.insertOne({
|
await articlesCollection.insertOne({
|
||||||
|
|||||||
Reference in New Issue
Block a user