Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymise expired order #11351

Open
5 tasks
korycins opened this issue Nov 30, 2022 · 0 comments
Open
5 tasks

Anonymise expired order #11351

korycins opened this issue Nov 30, 2022 · 0 comments
Labels
order rfc Request For Comments: blueprints of upcoming changes.

Comments

@korycins
Copy link
Member

korycins commented Nov 30, 2022

Problem

With the system to expire orders that are not paid, we need a solution to handle expired orders.
The proposition is to have a task, that will anonymize the expired orders after some time.
For all expired orders older than TTL, we should remove everything that is related to user.


1. General Assumptions

We are introducing a new Celery task that will be responsible for anonymizing all expired orders after exceeding the provided TTL.

Everything related to the user and attached to the order should be anonymized, including order.user, order.email, order.shipping_address, order.billing_address, and order.user_email.

The Celery task should be capable of handling high load. As an example implementation, we can use the one from issue #11257. The Celery beat should trigger the task once per day, and we should ensure that we do not call all high load Celery tasks at the same time.

The TTL (time-to-live) for anonymizing expired orders will be controlled by staff users through channel settings, similar to the one used for controlling expiring orders. Staff users will be able to provide a value in days (new scalar) within a range defined by Saleor, which is proposed to be from 1 to 60 days. The default value is 30 days.

For example, if an order expires on 2023-Jan-01 00:00:00 with the default value, it will be anonymized on 2023-Jan-31.

Acceptance Criteria

  • A staff user can set a Time To Live (TTL) for anonymizing orders.
  • Settings can be set by a user with permissions: MANAGE_ORDERS or MANAGE_CHANNELS
  • Once the TTL has expired, the order should have all user details removed.

2. API changes

"""
The `Day` scalar type represents number of days by integer value.
"""
scalar Day

input OrderSettingsInput @doc(category: "Orders") {

  """Anonymize expired orders time in days. Default 30. Enter 0 or null to disable. """
  anonymizeExpiredOrdersAfter: Day
}

type Channel {
   ...
   anonymizeExpiredOrdersAfter: Day!
}

3. Database changes

class Channel(models.Model):
    ...
    anonymize_expired_orders_after = models.IntegerField(default=None, null=True, blank=True)
class Order(models.Model):
    ...
    expired_at = models.DateTimeField(null=True, blank=True)

The expired_at field will be used to determine whether an order should be anonymized.

5. To Do list

Tasks

@korycins korycins changed the title Anonymize expired order Anonymise expired order Nov 30, 2022
@kadewu kadewu mentioned this issue Dec 21, 2022
14 tasks
@korycins korycins added payments Issues related to payments implementation rfc Request For Comments: blueprints of upcoming changes. order and removed payments Issues related to payments implementation labels Apr 13, 2023
@korycins korycins mentioned this issue Apr 13, 2023
3 tasks
@korycins korycins removed their assignment Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
order rfc Request For Comments: blueprints of upcoming changes.
Projects
None yet
Development

No branches or pull requests

1 participant