spree_cm_commissioner 2.3.0.pre.pre17 → 2.3.0.pre.pre19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76d6f1a36e751b1723a6a6f7d6ba016dcf6df4c24d4e66322fadd7cb6d99f133
4
- data.tar.gz: 5ee3fb8b1c36b92b04b349218a72db179b9e5afffe18342b73c6bafea2375600
3
+ metadata.gz: ba19c5f6b8ae1e8a80fb0128bf1f58b1a653d6430aa11d46ae3722b13e2d17be
4
+ data.tar.gz: 7993749d255ca3800e9d200adc21820bad68ac350a60b88882a5bda4ee054701
5
5
  SHA512:
6
- metadata.gz: d402702c7778ddf7a44be7b6370fb943c7e091ee1d9cc5214ac4ffa97fde73a2347f072692661a815daf85fd1a18441d44b79c2e4246fce686b5f9822554a5b5
7
- data.tar.gz: 3adbb3c9b40e612c65be67ae0853047bd5f1b1c82ac5daf7e91dc494a1f16d51f005eca9dbc48adf83467d3edb25e466114d9716abec8d43b0e7edff1b0753f2
6
+ metadata.gz: 83ffc09e4828acf4abb37b4d10e537f2302f967dca20fdf86a806f260fe733dbd9da4097a2f813650e29f2f1420350c538ec4aa8eedc7d9b7543a68e9c535d07
7
+ data.tar.gz: 40448782e45555c79e319cca373607a53ca34125ce1c5e13f45a74aa0014992a7294c768fdca9826287e645b2073a2f953eb2956ce983d1147d810f68a31c608
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (2.3.0.pre.pre17)
37
+ spree_cm_commissioner (2.3.0.pre.pre19)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -61,6 +61,7 @@ module Spree
61
61
 
62
62
  Spree::LineItem.joins(:order)
63
63
  .where(spree_orders: { token: order_tokens, state: 'complete', user_id: nil })
64
+ .includes(:guests, :saved_guests)
64
65
  .filter_by_event(event)
65
66
  .page(params[:page])
66
67
  .per(params[:per_page])
@@ -0,0 +1,12 @@
1
+ module SpreeCmCommissioner
2
+ module Orders
3
+ class ArchiveInactiveOrdersJob < ApplicationJob
4
+ # Scheduled job that runs daily to archive incomplete orders inactive for 14+ days.
5
+ # Thin wrapper that calls ArchiveInactiveOrders service.
6
+ # ApplicationJob handles error logging via around_perform hook.
7
+ def perform
8
+ SpreeCmCommissioner::Orders::ArchiveInactiveOrders.new.call
9
+ end
10
+ end
11
+ end
12
+ end
@@ -22,6 +22,11 @@ module SpreeCmCommissioner
22
22
  base.has_many :pending_guests, pending_guests_query, class_name: 'SpreeCmCommissioner::Guest', dependent: :destroy
23
23
  base.has_many :product_completion_steps, class_name: 'SpreeCmCommissioner::ProductCompletionStep', through: :product
24
24
 
25
+ base.has_many :saved_guests,
26
+ through: :guests,
27
+ source: :saved_guest,
28
+ class_name: 'SpreeCmCommissioner::SavedGuest'
29
+
25
30
  base.before_validation -> { self.product_type = variant.product_type || product.product_type }, if: -> { product_type.nil? }
26
31
 
27
32
  base.before_save :update_vendor_id
@@ -88,6 +88,7 @@ module SpreeCmCommissioner
88
88
  def restart_checkout_flow
89
89
  ActiveRecord::Base.transaction do
90
90
  cancel_blocks! if should_manage_blocks?
91
+ log_state_changes(state_name: 'cart', old_state: state, new_state: 'cart')
91
92
  update_columns( # rubocop:disable Rails/SkipsModelValidations
92
93
  state: 'cart',
93
94
  updated_at: Time.current
@@ -25,6 +25,8 @@ module Spree
25
25
 
26
26
  base.has_many :guests, serializer: SpreeCmCommissioner::V2::Storefront::GuestSerializer
27
27
 
28
+ base.has_many :saved_guests, serializer: SpreeCmCommissioner::V2::Storefront::SavedGuestSerializer
29
+
28
30
  base.has_many :pending_guests, serializer: SpreeCmCommissioner::V2::Storefront::GuestSerializer
29
31
 
30
32
  base.has_one :product, serializer: Spree::V2::Storefront::ProductSerializer
@@ -0,0 +1,55 @@
1
+ module SpreeCmCommissioner
2
+ module Orders
3
+ class ArchiveInactiveOrders
4
+ prepend ::Spree::ServiceModule::Base
5
+
6
+ # Archives incomplete orders that haven't been updated for 14 days.
7
+ # Archived orders are hidden from users (Orders::Find filters them out).
8
+ # Users will see an empty cart and can start a new one.
9
+ #
10
+ # Criteria for archiving:
11
+ # - archived_at IS NULL (not already archived)
12
+ # - completed_at IS NULL (incomplete/unfinished orders)
13
+ # - updated_at < 14 days ago (inactive for 2+ weeks)
14
+ #
15
+ # Why 14 days?
16
+ # - Gives users time to notice discontinued products and clean up their cart
17
+ # - If product is discontinued during these 14 days, users can manually clear
18
+ # their cart when they see the "unavailable" status in the UI
19
+ # - Gives the team time to investigate payment errors or stuck orders
20
+ #
21
+ # Why archive all payment states?
22
+ # - Data is preserved (archived_at is just a flag, not deletion)
23
+ # - Team can still review archived orders in the database if needed
24
+ # - Keeps user-facing order history clean (hidden from Orders::Find queries)
25
+ # - Reduces clutter in active carts/orders
26
+ def call
27
+ inactive_orders = Spree::Order
28
+ .where(archived_at: nil)
29
+ .where(completed_at: nil)
30
+ .where('updated_at < ?', 14.days.ago)
31
+
32
+ count = inactive_orders.count
33
+
34
+ # Archive all inactive orders with reason in internal_note
35
+ inactive_orders.update_all( # rubocop:disable Rails/SkipsModelValidations
36
+ archived_at: Time.current,
37
+ internal_note: 'Auto-archived: inactive for 14 days',
38
+ updated_at: Time.current
39
+ )
40
+
41
+ CmAppLogger.log(
42
+ label: 'SpreeCmCommissioner::Orders::ArchiveInactiveOrders#call completed',
43
+ data: {
44
+ archived_count: count,
45
+ threshold_days: 14
46
+ }
47
+ )
48
+
49
+ success(archived_count: count)
50
+ rescue StandardError => e
51
+ failure(nil, e.message)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '2.3.0-pre17'.freeze
2
+ VERSION = '2.3.0-pre19'.freeze
3
3
 
4
4
  module_function
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_cm_commissioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0.pre.pre17
4
+ version: 2.3.0.pre.pre19
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-12 00:00:00.000000000 Z
11
+ date: 2025-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree
@@ -1310,6 +1310,7 @@ files:
1310
1310
  - app/jobs/spree_cm_commissioner/option_type_variants_public_metadata_updater_job.rb
1311
1311
  - app/jobs/spree_cm_commissioner/option_value_variants_public_metadata_updater_job.rb
1312
1312
  - app/jobs/spree_cm_commissioner/order_complete_telegram_sender_job.rb
1313
+ - app/jobs/spree_cm_commissioner/orders/archive_inactive_orders_job.rb
1313
1314
  - app/jobs/spree_cm_commissioner/product_event_id_to_children_syncer_job.rb
1314
1315
  - app/jobs/spree_cm_commissioner/queue_order_webhooks_requests_job.rb
1315
1316
  - app/jobs/spree_cm_commissioner/reports_assigner_job.rb
@@ -1952,6 +1953,7 @@ files:
1952
1953
  - app/services/spree_cm_commissioner/intercity_taxi_order/update.rb
1953
1954
  - app/services/spree_cm_commissioner/metafields/product_metadata_service.rb
1954
1955
  - app/services/spree_cm_commissioner/order_params_checker.rb
1956
+ - app/services/spree_cm_commissioner/orders/archive_inactive_orders.rb
1955
1957
  - app/services/spree_cm_commissioner/orders/generate_commissions_decorator.rb
1956
1958
  - app/services/spree_cm_commissioner/organizer/export_guest_csv_service.rb
1957
1959
  - app/services/spree_cm_commissioner/organizer/export_invite_guest_csv_service.rb