Skip to content

Instantly share code, notes, and snippets.

@chrisroos chrisroos/affected-ids.rb
Last active Mar 20, 2018

Embed
What would you like to do?
# These were the IDs returned by the identify-affected-attachments.rb script when it was run in staging on 20 Mar 2018.
#
[3625, 6002, 6007, 7874, 7875, 12248, 12249, 16333, 16381, 16383, 27263, 27607, 28153, 28154, 48876, 65687, 69606, 97881, 118296, 137087, 137587, 151994, 151995, 151996, 152690, 156319, 163466, 163467, 163468, 163469, 163470, 163471, 167849, 167851, 172237, 172238, 172239, 176752, 176753, 179306, 180955, 182610, 182636, 184031, 190436, 190437, 190438, 190439, 198104, 198144, 203773, 203952, 206956, 210410, 210933, 211644, 211646, 212271, 222544, 222545, 226017, 226119, 230027, 232152, 245882, 246519, 249795, 249796, 251493, 255473, 256038, 256798, 257471, 259192, 259868, 260418, 260904, 263013, 263014, 263359, 266717, 266834, 268678, 268679, 268680, 268681, 268682, 268683, 268684, 268685, 268686, 268687, 270767, 271065, 273957, 273959, 276018, 276347,276696, 276698, 278305, 279330, 281943, 284025, 284200, 284202, 284203, 284204, 284205, 284208, 284962, 286668, 286670, 287941, 288107, 288108, 290000, 290001, 294582, 294604, 296223, 300231, 301320, 305419, 305420, 305421, 306000, 306818, 307523, 311735, 317371, 317974, 318866, 319460, 319464, 322097, 323538, 323719, 323807, 324099, 325074, 328852, 328854, 329354, 335111, 338498, 341175, 341176, 341177, 346304, 347565, 348700, 349288, 353102, 353103, 354193, 354201, 354205, 354233, 354234, 354240, 354263, 354264, 354269, 354273, 354281, 354282, 354305, 354309, 354315, 354317, 354321, 354329, 354331, 354342, 354350, 354354, 354362, 354383, 354386, 354388, 354391, 354415, 354419, 354427, 354428, 354436, 354446, 354447, 354452, 354458, 354460, 354472, 354473, 354476, 354480, 354486, 354512, 354516, 354522, 354560, 354564, 354576, 354580, 354597, 354602, 354606, 354612, 354614, 355831, 356185, 356211, 360402, 364911, 366478, 367724, 369464, 370234, 371426, 372427, 373530, 373593, 373610, 375373, 378733,378804, 379081, 380161, 380726, 380819, 384047, 385114, 385241, 385470, 385473, 385478, 385483, 385487, 385507, 385516, 385687, 387774, 389042, 391982, 391986, 391990, 392023, 392038, 392077, 392100, 392126, 392267, 392284, 392292, 392300, 392301, 392513, 393454, 393558, 393700, 394486, 395190, 396904, 396990, 397431, 397955, 399078, 400896, 401623, 401633, 402297, 405528, 409105, 409389, 409934, 410411, 410881, 410895, 411838, 413281, 413993, 414082, 414784, 416171, 416943, 416954, 416958, 416960, 416963, 417151, 417875, 417998, 419275, 420447, 420504, 424106, 424377, 424821, 426371, 427401, 427402, 429016, 431187, 431315, 431316, 431981, 431998, 432001, 434410, 434610, 435603, 435698, 438318, 439629, 440174, 440235, 440528, 441417, 441799, 441800, 442792, 442896, 442960, 443342, 445758, 446594, 446756, 448063, 448068, 448642, 448793, 449772, 450558, 453454, 453854, 453855, 453856, 454381, 454630, 454631, 458128, 458220, 458266, 458453, 460295, 460585, 461116, 462833, 463730, 464257, 464286, 464528,465728, 466271, 467107, 467778, 469367, 469685, 470735, 475769, 478830, 479592, 479593, 479596, 479597, 481811, 482836, 483052, 483203, 483642, 485831, 485953, 490852, 496100, 500213, 501311, 502981, 503532, 503768, 505746, 506150, 506918, 507618, 508213, 511951, 515358, 519135, 523744, 523763, 523764, 524131, 524525, 524720, 524912, 525856, 530344, 531360, 531361, 531707, 531708, 531709, 531729, 531731, 531732, 531857, 531858, 531859, 533543, 533761, 536054, 536055, 536056, 536096, 537626, 538901, 539392, 539708, 543575, 547148, 547151, 549037, 549246, 549296, 550176, 550177, 550180, 550181, 550662, 551804, 552044, 552903, 553257, 553288, 553437, 554758, 557239, 557656, 557660, 557684, 557691, 559635, 560041, 560127, 562272, 562274, 563736, 563737, 566827, 567055, 568224, 568268, 571984, 572091, 572096, 573221, 573673, 573894, 575417, 576195, 576691, 578904, 579300, 579305, 579309, 579463, 579505, 581397, 583159, 587160, 589202, 589531, 589924, 589926, 590247, 590301, 590697, 590698, 590712, 590762,590763, 590773, 590825, 590826, 591047, 591398, 591410, 591417, 591423, 591789, 593163, 593867, 595227, 595845, 598271, 599282, 599844, 600490, 601188, 601544, 601556, 601580, 601582, 601624, 603323, 603417, 603418, 604019, 605428, 606356, 606357, 606530, 606531, 607222, 608030, 608429, 608875, 609775, 610510, 610582, 611324, 612094, 612891, 613085, 613690, 615589, 616105, 621859, 621891, 622037, 622127, 622129, 622145, 622191, 622200, 622206, 622208, 622209, 627919, 629881, 634057, 635869, 636157, 636173, 637599, 640748, 640785, 641154, 641155, 641157, 641158, 641563, 641564, 641567, 641569, 641599, 641601, 643257, 643754, 643856, 644474, 644476, 647192, 647193, 647482, 650975, 651202, 652622, 654622, 654623, 656409, 657408, 657518, 658211, 658257, 658361, 658992, 660041, 660701, 661356, 661459, 662698, 662954, 662956, 662984, 663142, 663459, 663493, 663551, 663765, 663843, 664059, 665307, 665459, 666841, 673397, 674141, 674743, 675211, 675499, 675880, 675883, 675899, 675901, 676136, 677307, 677309,677431, 678549, 679543, 679545, 681330, 682030, 682032, 682279, 682281, 682747, 683185, 683220, 684327, 686048, 687295, 687462, 691646]
# Script to identify the attachments affected by the change in https://github.com/alphagov/whitehall/pull/3874
# To use:
# 1. SSH onto whitehall_backend machine
# 2. Run `sudo su - deploy`
# 3. Save this script as /tmp/identify-affected-attachments.rb
# 4. Run `cd /var/apps/whitehall`
# 5. Run `govuk_setenv whitehall bundle exec rails r /tmp/identify-affected-attachments.rb`
affected_ids = []
AttachmentData.find_each.with_index do |attachment_data, index|
if index % 500 == 0
print '.'
end
visible_to_including_replaced = !attachment_data.deleted? &&
!attachment_data.unpublished? &&
!attachment_data.replaced? &&
(!attachment_data.draft? || (attachment_data.draft? && attachment_data.accessible_to?(nil)))
unless attachment_data.visible_to?(nil) == visible_to_including_replaced
affected_ids << attachment_data.id
end
end
puts
p affected_ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.