Add date_upd as it's updated when customer connect after 5 days
This commit is contained in:
parent
85c8d7d699
commit
dfbd8a23b4
@ -16,10 +16,13 @@ versions = ['fr','es'];
|
||||
for version in versions:
|
||||
for year in range(2012, now.year + 1):
|
||||
fp = open("extracts/weekly/%d-%02d-%02d_%d_%s.csv" % (now.year, now.month, now.day, year, version), "wb")
|
||||
#fp = open("extracts/weekly/2017-11-06_%d_%s.csv" % (year,version), "wb")
|
||||
f = csv.DictWriter(
|
||||
fp,
|
||||
["id_customer", "email", "sponsor_id", "sponsor_email", "date_add", "total_orders_amount", "total_orders", "newsletter", "optin", "first_order", "second_order", "last_order", "nb_orders_3", "nb_orders_6", "nb_orders_9", "nb_orders_12", "balise_ed", ],
|
||||
[
|
||||
"id_customer", "email", "sponsor_id", "sponsor_email", "date_add", "date_upd", "total_orders_amount",
|
||||
"total_orders", "newsletter", "optin", "first_order", "second_order", "last_order", "nb_orders_3",
|
||||
"nb_orders_6", "nb_orders_9", "nb_orders_12", "balise_ed",
|
||||
],
|
||||
delimiter=";", quotechar='"', quoting=csv.QUOTE_MINIMAL
|
||||
)
|
||||
|
||||
@ -31,7 +34,7 @@ for version in versions:
|
||||
# Si FR on prends tout sauf les ES
|
||||
if version == "fr":
|
||||
customers = c.query("""
|
||||
SELECT c.`id_customer`, c.`email`, c.`date_add`, c.`optin`, c.`newsletter`
|
||||
SELECT c.`id_customer`, c.`email`, c.`date_add`, c.`date_upd`, c.`optin`, c.`newsletter`
|
||||
FROM `ps_customer` c
|
||||
WHERE c.`date_add` < "%d-%02d-%02d 23:59:59"
|
||||
AND c.`date_add` >= "%d-%02d-01 00:00:00"
|
||||
@ -46,7 +49,7 @@ for version in versions:
|
||||
# sinon on LEFT JOIN sur la version en cours
|
||||
else :
|
||||
customers = c.query("""
|
||||
SELECT c.`id_customer`, c.`email`, c.`date_add`, c.`optin`, c.`newsletter`
|
||||
SELECT c.`id_customer`, c.`email`, c.`date_add`, c.`date_upd`, c.`optin`, c.`newsletter`
|
||||
FROM `ps_customer` c
|
||||
LEFT JOIN `ps_customer_version` cv ON (cv.`id_customer` = c.`id_customer`)
|
||||
WHERE c.`date_add` < "%d-%02d-%02d 23:59:59"
|
||||
@ -177,8 +180,9 @@ for version in versions:
|
||||
"id_customer": customer["id_customer"],
|
||||
"email": customer["email"],
|
||||
"sponsor_id": sponsors.get(customer["id_customer"], ("", ""))[0],
|
||||
"sponsor_email": sponsors.get(customer["id_customer"], ("", ""))[1],
|
||||
"sponsor_email": sponsors.get(customer["id_customer"], ("", ""))[1],
|
||||
"date_add": customer["date_add"],
|
||||
"date_upd": customer["date_upd"],
|
||||
"total_orders_amount": orders.get(customer["id_customer"], ["0.0"])[0],
|
||||
"total_orders": orders.get(customer["id_customer"], ["0.0", "0"])[1],
|
||||
"newsletter": customer["newsletter"],
|
||||
|
Loading…
Reference in New Issue
Block a user