Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bas/shared_storage/elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def read_body
]
}
},
sort: [{ inserted_at: { order: "asc" } }]
sort: [{ inserted_at: { order: "desc" } }]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Verify test coverage and confirm the intended processing order.

The change from ascending to descending order means the most recently inserted document will now be processed first (LIFO) instead of the oldest (FIFO). This is a significant behavioral change that could impact consumers of this API.

Please verify:

  1. Test coverage exists for this sorting behavior
  2. No consumers depend on the previous FIFO ordering
  3. This descending order aligns with the intended business requirements

Run the following script to check for related tests and usage:


🏁 Script executed:

#!/bin/bash
# Description: Find tests and usages related to Elasticsearch shared storage ordering

# Search for test files related to Elasticsearch shared storage
echo "=== Test files for Elasticsearch shared storage ==="
fd -e rb -g '*elasticsearch*' -g '*spec*' -g '*test*'

# Search for assertions or expectations about ordering/sorting
echo -e "\n=== Test assertions about sorting or ordering ==="
rg -n -C3 --type=ruby 'inserted_at|sort|order|first|FIFO|LIFO' -g '*spec*' -g '*test*'

# Search for usages of the read method from Elasticsearch class
echo -e "\n=== Usages of SharedStorage::Elasticsearch read method ==="
rg -n -C3 --type=ruby 'SharedStorage::Elasticsearch|Elasticsearch.*\.read'

Length of output: 5424


Add tests covering descending inserted_at sorting behavior
Currently only the single-hit case is tested; add specs in spec/bas/shared_storage/elasticsearch_spec.rb verifying multiple results are returned newest-first, and confirm no downstream consumers depend on FIFO ordering or conflict with business requirements.

}
end

Expand Down
Loading