Skip to content

Commit 1f617c9

Browse files
Display removed merchants count and soft removal date to Github issue
1 parent ac02a60 commit 1f617c9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

app/services/merchants/check_and_report_removed_on_osm.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def call
1818
return if @diff_ids.empty?
1919

2020
# Mark record as soft deleted
21-
merchants.update_all(deleted_at: Time.current)
21+
merchants
22+
.where(deleted_at: nil)
23+
.update_all(deleted_at: Time.current)
2224

2325
if Rails.env.test? || Rails.env.production?
2426
# Report to Github issue merchants removed from OSM
@@ -39,7 +41,7 @@ def call
3941

4042
def body
4143
<<~MARKDOWN
42-
Some merchants seems to have been removed on OpenStreetMap but are still present in Bank-Exit.org website.
44+
**#{merchants_list.count}** merchants seems to have been removed on OpenStreetMap but are still present in Bank-Exit.org website.
4345
Please check the relevance of the information below:
4446
4547
#{merchants_list.join("\n")}
@@ -51,13 +53,14 @@ def body
5153
end
5254

5355
def merchants
54-
@merchants ||= Merchant.where(original_identifier: @diff_ids)
56+
@merchants ||= Merchant.where(original_identifier: @diff_ids).order(deleted_at: :desc)
5557
end
5658

5759
def merchants_list
5860
@merchants_list ||= MerchantDecorator.wrap(merchants).map do |merchant|
5961
<<~MARKDOWN
6062
- [ ] **#{merchant.name}** [##{merchant.identifier}] #{pretty_country_html(merchant.country, show_flag: true)}
63+
- Date: #{I18n.l(merchant.deleted_at)}
6164
- [On Bank-Exit](#{merchant_url(merchant, debug: 'true')})
6265
- [On OpenStreetMap](#{merchant.osm_link})
6366
MARKDOWN

spec/services/merchants/check_and_report_removed_on_osm_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
end
1515

1616
before do
17+
freeze_time
18+
1719
stub_request(:patch, /api.github.com/)
1820
.with(body: {
1921
body: <<~MARKDOWN
20-
Some merchants seems to have been removed on OpenStreetMap but are still present in Bank-Exit.org website.
22+
**1** merchants seems to have been removed on OpenStreetMap but are still present in Bank-Exit.org website.
2123
Please check the relevance of the information below:
2224
2325
- [ ] **John** [#1234ABCD] 🇫🇷 France
26+
- Date: #{I18n.l(Time.current)}
2427
- [On Bank-Exit](http://example.test/en/merchants/1234ABCD-john?debug=true)
2528
- [On OpenStreetMap](https://www.openstreetmap.org/node/1234ABCD)
2629

0 commit comments

Comments
 (0)