-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rake tasks ran for refining output for AttachmentData deleted? true
- Loading branch information
1 parent
cdb69c5
commit 720d16d
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
desc "Check assets" | ||
task check_assets: :environment do | ||
file = File.open("./lib/tasks/attachments/attachment_data_deleted_in_wh_replaced_in_both_but_replacements_are_draft.txt", "a") | ||
|
||
File.readlines("./lib/tasks/attachments/ads_to_check.txt", chomp: true).each do |line| | ||
attachment_data_id, asset_manager_id, = line.split(",") | ||
|
||
begin | ||
asset_manager_response = GdsApi.asset_manager.asset(asset_manager_id).to_h | ||
rep_response = GdsApi.asset_manager.asset(asset_manager_response["replacement_id"]).to_h | ||
rescue GdsApi::HTTPNotFound | ||
next | ||
end | ||
|
||
if rep_response["draft"] | ||
puts "ad: #{attachment_data_id}, am_id: #{asset_manager_id}, rep_id: #{asset_manager_response['replacement_id']}, rep_del: #{rep_response['deleted']}, rep_rep: #{!rep_response['replacement_id'].nil?}" << "\n" | ||
file << "#{attachment_data_id},#{asset_manager_id},#{asset_manager_response['replacement_id']},#{rep_response['deleted']},#{!rep_response['replacement_id'].nil?}" << "\n" | ||
else | ||
print "." | ||
end | ||
end | ||
|
||
file.close | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
desc "Check attachables" | ||
task check_attachables: :environment do | ||
File.readlines("./lib/tasks/attachments/ads_to_check.txt", chomp: true).each do |line| | ||
attachment_data_id = line.split(",").first | ||
states = AttachmentData.find(attachment_data_id).attachments.map(&:attachable).map { |a| a&.state } | ||
if !valid_state(states) | ||
puts "NOT OK: #{attachment_data_id}: [#{states.join(', ')}]" | ||
else | ||
print "." | ||
end | ||
end | ||
end | ||
|
||
def valid_state(states) | ||
return false unless states[-1].nil? | ||
return false unless states.reject { |state| ["superseded", nil].include? state }.empty? | ||
|
||
true | ||
end |
29 changes: 29 additions & 0 deletions
29
lib/tasks/attachments/investigate_ad_deleted_not_replaced_in_wh.rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
desc "investigate_ad_deleted_not_replaced_in_wh" | ||
task investigate_ad_deleted_not_replaced_in_wh: :environment do | ||
file = File.open("./lib/tasks/attachments/investigate_ad_deleted_not_replaced_in_wh.txt", "a") | ||
|
||
items = [{ "ad": "119997", "am_id": "5a74c12b40f0b619c865a2b5" }, { "ad": "215680", "am_id": "5a7b893eed915d4147621035" }, { "ad": "215681", "am_id": "5a7c5637e5274a2041cf3552" }, { "ad": "215682", "am_id": "5a74f918ed915d502d6cc7e0" }, { "ad": "348517", "am_id": "5a7e138ded915d74e6223f31" }, { "ad": "348518", "am_id": "5a7e0ac840f0b62305b806ba" }, { "ad": "417520", "am_id": "5a80e8c0e5274a2e87dbc810" }, { "ad": "417520", "am_id": "5a80e8c0e5274a2e8ab52d99" }, { "ad": "429632", "am_id": "5a74a818e5274a56317a614e" }, { "ad": "429632", "am_id": "5a74a818ed915d0e8bf1a12f" }, { "ad": "438405", "am_id": "5a8157e0e5274a2e87dbd1d6" }, { "ad": "438405", "am_id": "5a8157e140f0b62302696cb2" }, { "ad": "559781", "am_id": "5a748242ed915d0e8e398c40" }, { "ad": "571780", "am_id": "5a7481dd40f0b604dd7ae7b3" }, { "ad": "589786", "am_id": "5a80369b40f0b62305b89d84" }, { "ad": "589786", "am_id": "5a803699e5274a2e87db8843" }, { "ad": "622647", "am_id": "5a823ae6ed915d74e34026ce" }, { "ad": "654312", "am_id": "5a820f73e5274a2e87dc0ef8" }, { "ad": "659103", "am_id": "5a8224dfe5274a2e8ab57b90" }, { "ad": "674082", "am_id": "5a74817440f0b604dd7ae776" }, { "ad": "681582", "am_id": "5a845946ed915d74e6238835" }, { "ad": "688394", "am_id": "5aa6b4c1e5274a3e3603a86d" }, { "ad": "693189", "am_id": "5ab3b42840f0b65bb8ef2035" }, { "ad": "693189", "am_id": "5ab3b42840f0b65bb5842994" }, { "ad": "693190", "am_id": "5ab3b4d6e5274a3dcb6dd1ac" }, { "ad": "693190", "am_id": "5ab3b4d640f0b65bb5842997" }, { "ad": "693192", "am_id": "5ab3b5bced915d4f2d097280" }, { "ad": "693192", "am_id": "5ab3b5bde5274a3dc898e319" }, { "ad": "700701", "am_id": "5ad73699ed915d32a3a70cd1" }, { "ad": "705481", "am_id": "5af1c391e5274a698b72e811" }, { "ad": "705481", "am_id": "5af1c391ed915d5869f41933" }, { "ad": "713227", "am_id": "5b115d34ed915d2cc681ab6f" }, { "ad": "713227", "am_id": "5b115d34ed915d2cd274dc0f" }, { "ad": "713235", "am_id": "5b115db440f0b634d14c2209" }, { "ad": "713235", "am_id": "5b115db3ed915d2cc8317509" }, { "ad": "713329", "am_id": "5b1169b1e5274a18fa9d38e4" }, { "ad": "718446", "am_id": "5b2baf9240f0b67f769a7353" }, { "ad": "718852", "am_id": "5b2d11eae5274a55da87efb5" }, { "ad": "734552", "am_id": "5b758339ed915d14d5936cf3" }, { "ad": "738234", "am_id": "5b8f792fe5274a0be10a1179" }, { "ad": "739408", "am_id": "5b9678bded915d66571c326e" }, { "ad": "739411", "am_id": "5b967915ed915d666303c44b" }, { "ad": "739411", "am_id": "5b967915e5274a13a7fd9595" }, { "ad": "739412", "am_id": "5b96799a40f0b67896977b4d" }, { "ad": "739412", "am_id": "5b96799aed915d665412c9c8" }, { "ad": "744919", "am_id": "5bb3476040f0b62dd06e3278" }, { "ad": "744919", "am_id": "5bb34760e5274a3e10bd93a3" }, { "ad": "745079", "am_id": "5bb38937ed915d07704fb713" }, { "ad": "745079", "am_id": "5bb3893740f0b64a1f91648a" }, { "ad": "746115", "am_id": "5bb72b4fe5274a223236df18" }, { "ad": "746115", "am_id": "5bb72b4fe5274a222b994bba" }, { "ad": "747595", "am_id": "5bbf2562ed915d733ef99cd4" }, { "ad": "747596", "am_id": "5bbf258440f0b6384eb145c9" }, { "ad": "749354", "am_id": "5bcd5992e5274a6bd56072ec" }, { "ad": "749354", "am_id": "5bc84da7e5274a122a786749" }, { "ad": "750167", "am_id": "5bcd915de5274a6bd864f34e" }, { "ad": "750167", "am_id": "5bcd915ded915d432e3c62bb" }, { "ad": "750680", "am_id": "5bcf0ae4ed915d4346a3a9a8" }, { "ad": "750680", "am_id": "5bcf0ae440f0b6442b5d12a2" }, { "ad": "751204", "am_id": "5bd0837c40f0b6051ce5de56" }, { "ad": "751204", "am_id": "5bd0837ce5274a6e3cff0c9e" }, { "ad": "751205", "am_id": "5bd08397e5274a6e39bf2b93" }, { "ad": "751205", "am_id": "5bd0839740f0b604cbff2294" }, { "ad": "751525", "am_id": "5bd1cda2e5274a6e1f36edb9" }, { "ad": "751525", "am_id": "5bd1cda240f0b6051ce5de73" }, { "ad": "756087", "am_id": "5bec099240f0b667cb8b318a" }, { "ad": "756087", "am_id": "5bec0992ed915d6a23c800b5" }, { "ad": "756819", "am_id": "5bf3adb3ed915d1822db2531" }, { "ad": "756819", "am_id": "5beea65f40f0b667c116bee3" }, { "ad": "765565", "am_id": "5c17cdcced915d0c221e47b9" }, { "ad": "767553", "am_id": "5c1ccd0540f0b66d07956774" }, { "ad": "767553", "am_id": "5c1ccd05e5274a65c15425d2" }, { "ad": "769159", "am_id": "5c35edbae5274a659322b1d3" }, { "ad": "769159", "am_id": "5c332c0140f0b66d079567e6" }, { "ad": "792037", "am_id": "5ca38c0b40f0b625e86eb23b" }, { "ad": "792037", "am_id": "5ca38c0be5274a77d3b93a24" }, { "ad": "803479", "am_id": "5ce52b9eed915d24811db1c0" }, { "ad": "804536", "am_id": "5cf5bd56ed915d030129f18c" }, { "ad": "804651", "am_id": "5cf5d082e5274a076158e6b0" }, { "ad": "804666", "am_id": "5cf5e68540f0b60a1afd2f97" }, { "ad": "809636", "am_id": "5d08ab2940f0b6094c6c8d50" }, { "ad": "823181", "am_id": "5d47cf0ded915d706672c810" }, { "ad": "823181", "am_id": "5d47cf0ded915d7060de6125" }, { "ad": "826069", "am_id": "5d5a9e52e5274a07655d5b43" }, { "ad": "829632", "am_id": "5d70e9fb40f0b6092247e41b" }, { "ad": "840965", "am_id": "5db66aa640f0b637a2b059fd" }, { "ad": "841940", "am_id": "5db6c0f3ed915d1d07006e7b" }, { "ad": "841941", "am_id": "5db57b78ed915d1d0c3b7e7a" }, { "ad": "848719", "am_id": "5de6fcdc40f0b650bf4dee49" }, { "ad": "854409", "am_id": "5dfcad71e5274a33f074fefc" }, { "ad": "864729", "am_id": "5e4175a4e5274a08e229ca6f" }, { "ad": "871877", "am_id": "5e6ad16ae90e070ac49db163" }, { "ad": "871877", "am_id": "5e6ad2afe90e070acbbcd22d" }, { "ad": "871884", "am_id": "5e6ad307d3bf7f2692fa8d8c" }, { "ad": "871887", "am_id": "5e6ad2a5e90e070acd195b4d" }, { "ad": "871887", "am_id": "5e68d928e90e070acbbcd208" }, { "ad": "876566", "am_id": "5e7e4ca3e90e0706fc3ffa22" }, { "ad": "876567", "am_id": "5e7e508cd3bf7f134447df8d" }, { "ad": "877574", "am_id": "5e85a9fd86650c74423c9aba" }, { "ad": "880051", "am_id": "5e99b0c5e90e0704918ce3f6" }, { "ad": "880996", "am_id": "5ea1c4c2e90e07048d8ecc7f" }, { "ad": "882883", "am_id": "5eaee5fad3bf7f65241db060" }, { "ad": "883855", "am_id": "5eb3f577d3bf7f5d37fa0d1b" }, { "ad": "888352", "am_id": "5ed4e4abe90e0754d3f5eed5" }, { "ad": "888391", "am_id": "5ed51bc7d3bf7f45fcf2c5df" }, { "ad": "888416", "am_id": "5ed5c8fe86650c76b2fe7529" }, { "ad": "888421", "am_id": "5ed5c7e3d3bf7f4600d9f3eb" }, { "ad": "888453", "am_id": "5ed5d8aae90e0754d4e62535" }, { "ad": "888523", "am_id": "5ed5e9a5e90e0754cc92fb59" }, { "ad": "889195", "am_id": "5ed63148e90e0754cd08d6a4" }, { "ad": "890465", "am_id": "5eda4b9dd3bf7f45ff9c286f" }, { "ad": "890466", "am_id": "5eda4bc986650c4ac13b1e64" }, { "ad": "890467", "am_id": "5eda4beee90e071b7a39a660" }, { "ad": "897289", "am_id": "5efdcb723a6f4023d1e338fe" }, { "ad": "899839", "am_id": "5f0c3d4fe90e070320aadff2" }, { "ad": "899932", "am_id": "5f0e4d52e90e070312c4c471" }, { "ad": "900032", "am_id": "5f0c7a47e90e07031cfbeab8" }, { "ad": "900858", "am_id": "5f0ee6bdd3bf7f03ab8a4e46" }, { "ad": "901533", "am_id": "5f1175ef3a6f405c0e3b2c9e" }, { "ad": "901940", "am_id": "5f154f973a6f405c0f80ac20" }, { "ad": "903373", "am_id": "5f199047e90e07456894011c" }, { "ad": "903755", "am_id": "5f1af1c63a6f4072725b04fc" }, { "ad": "907446", "am_id": "5f2be735e90e0732ddaf4234" }, { "ad": "911207", "am_id": "5f3fcea7e90e07529d276a73" }, { "ad": "919314", "am_id": "5f64cae9d3bf7f723e21c115" }, { "ad": "920491", "am_id": "5f6b26bfe90e077ca74b2a05" }, { "ad": "925120", "am_id": "5f7ee917e90e077417b16bd7" }, { "ad": "925121", "am_id": "5f7ee940d3bf7f019526cd33" }, { "ad": "925122", "am_id": "5f7ee9608fa8f51e789b7599" }, { "ad": "925161", "am_id": "5f85a6e4d3bf7f6ba4f450a3" }, { "ad": "925161", "am_id": "5f7f0163e90e077418bbba06" }, { "ad": "941701", "am_id": "5fd955a7d3bf7f40d2f0a657" }, { "ad": "941701", "am_id": "5fce40fc8fa8f54d6480f471" }, { "ad": "957939", "am_id": "601b736fe90e07128e743bb2" }, { "ad": "961280", "am_id": "6026aa508fa8f5037d3719bb" }, { "ad": "980434", "am_id": "6087b3cdd3bf7f01343a0777" }, { "ad": "980451", "am_id": "6087c0f98fa8f51b91f3d7fc" }, { "ad": "980487", "am_id": "6087ccf38fa8f51b8da251e1" }, { "ad": "980491", "am_id": "6087cd388fa8f51b940100a7" }, { "ad": "980502", "am_id": "6087d05ae90e076aa7da9989" }, { "ad": "980508", "am_id": "6087d14fe90e076ab285aed9" }, { "ad": "980516", "am_id": "6087d45ed3bf7f0133234d01" }, { "ad": "980528", "am_id": "6087d931d3bf7f0133234d02" }, { "ad": "980532", "am_id": "6087dbb5e90e076aad25a5af" }, { "ad": "980536", "am_id": "6087dc898fa8f51b92e94d66" }, { "ad": "980541", "am_id": "6087df6dd3bf7f0139670b8b" }, { "ad": "980638", "am_id": "6087fa258fa8f51b95cc0a00" }, { "ad": "980667", "am_id": "608805208fa8f51b8b34c887" }, { "ad": "980689", "am_id": "608813c98fa8f51b9988cbd2" }, { "ad": "980777", "am_id": "60881c4dd3bf7f013633281b" }, { "ad": "980797", "am_id": "60881f89d3bf7f01343a0795" }, { "ad": "981011", "am_id": "60883569e90e076aad25a5c0" }, { "ad": "981067", "am_id": "60883aae8fa8f51b8f716cc9" }, { "ad": "981069", "am_id": "60883b0f8fa8f51b98b150bf" }, { "ad": "981581", "am_id": "608934928fa8f51b940100d5" }, { "ad": "981600", "am_id": "60893753e90e076aaca7d6aa" }, { "ad": "984846", "am_id": "60996fac8fa8f56a3c1629c0" }, { "ad": "987078", "am_id": "60a37164d3bf7f288f04e514" }, { "ad": "997707", "am_id": "60db174b8fa8f50abc106be4" }, { "ad": "1032258", "am_id": "618a86dad3bf7f56080b1d5c" }, { "ad": "1070064", "am_id": "62611e02d3bf7f55c5f50fc6" }, { "ad": "1075634", "am_id": "628297b2e90e071f5d4f1c6c" }, { "ad": "1075702", "am_id": "62827c7ae90e071f5ee0e78d" }, { "ad": "1075704", "am_id": "62827c7ae90e071f646c6b55" }, { "ad": "1075761", "am_id": "6282889f8fa8f55615524db7" }, { "ad": "1075814", "am_id": "628289dde90e071f62029b98" }, { "ad": "1075818", "am_id": "62828a5d8fa8f5561f02a38b" }, { "ad": "1075892", "am_id": "62828a5fe90e071f646c6b5d" }, { "ad": "1075898", "am_id": "62828a9d8fa8f5561cd9b1e2" }, { "ad": "1089182", "am_id": "62c7fe79d3bf7f2ffaa4a9f2" }, { "ad": "1161030", "am_id": "647de988b32b9e0012a961f4" }, { "ad": "1161030", "am_id": "647de988103ca60013039962" }, { "ad": "1164980", "am_id": "649555bb9e7a8b000c932a60" }, { "ad": "1170995", "am_id": "64b50323995900000d002b80" }, { "ad": "1170997", "am_id": "64b5033007d4b8001334739e" }, { "ad": "1170998", "am_id": "64b5033d07d4b8000d347380" }, { "ad": "1213255", "am_id": "65a9510ab2f3c6000de5d56e" }, { "ad": "1213255", "am_id": "65a9510aed27ca000d27b268" }, { "ad": "1229914", "am_id": "65fdad14a6c0f7001aef9319" }, { "ad": "1229915", "am_id": "65fdad29f1d3a0001d32ae6b" }, { "ad": "1229916", "am_id": "65fdad3465ca2f00117da945" }, { "ad": "1229917", "am_id": "65fdad3ea6c0f7001aef931a" }, { "ad": "1229918", "am_id": "65fdad4965ca2f00117da946" }, { "ad": "1229919", "am_id": "65fdad5465ca2ffef17da781" }, { "ad": "1229921", "am_id": "65fdad6265ca2f00117da949" }, { "ad": "1229922", "am_id": "65fdad85a6c0f7001aef931c" }, { "ad": "1229923", "am_id": "65fdad90f1d3a0001d32ae6d" }, { "ad": "1229924", "am_id": "65fdad9f65ca2ffef17da783" }, { "ad": "1253893", "am_id": "669923d6ab418ab055592824" }, { "ad": "1258311", "am_id": "66b1bde349b9c0597fdb0af7" }, { "ad": "1258311", "am_id": "66b1bde3fc8e12ac3edb0abd" }] | ||
|
||
items.each do |item| | ||
attachment_data = AttachmentData.find(item[:ad]) | ||
asset_id = item[:am_id] | ||
begin | ||
asset_manager_response = GdsApi.asset_manager.asset(asset_id).to_h | ||
replacement_id = asset_manager_response["replacement_id"] | ||
replacement_response = replacement_id ? GdsApi.asset_manager.asset(replacement_id).to_h : nil | ||
rescue GdsApi::HTTPNotFound | ||
next | ||
end | ||
|
||
rep_del = replacement_response ? !replacement_response["deleted"].nil? : "nil" | ||
rep_draft = replacement_response ? !replacement_response["draft"].nil? : "nil" | ||
has_unpublished_attachable = attachment_data.attachments.map(&:attachable).map { |a| a&.state }.include?("unpublished") | ||
has_published_attachable = attachment_data.attachments.map(&:attachable).map { |a| a&.state }.include?("published") | ||
has_withdrawn_attachable = attachment_data.attachments.map(&:attachable).map { |a| a&.state }.include?("withdrawn") | ||
|
||
puts "ad: #{attachment_data.id}, am_id: #{asset_id}, rep: #{!asset_manager_response['replacement_id'].nil?}, rep_del: #{rep_del}, rep_draft: #{rep_draft}, draft: #{asset_manager_response['draft']}, unpublished_attachable: #{has_unpublished_attachable}, redirect: #{!asset_manager_response['redirect_url'].nil?}, withdrawn_attachable: #{has_withdrawn_attachable}, published_attachable: #{has_published_attachable}" | ||
file << "ad: #{attachment_data.id}, am_id: #{asset_id}, rep: #{!asset_manager_response['replacement_id'].nil?}, rep_del: #{rep_del}, rep_draft: #{rep_draft}, draft: #{asset_manager_response['draft']}, unpublished_attachable: #{has_unpublished_attachable}, redirect: #{!asset_manager_response['redirect_url'].nil?}, withdrawn_attachable: #{has_withdrawn_attachable}, published_attachable: #{has_published_attachable}" << "\n" | ||
end | ||
|
||
file.close | ||
end |