Skip to content

Instantly share code, notes, and snippets.

@dayyan
Created February 6, 2018 18:46
Show Gist options
  • Select an option

  • Save dayyan/fb147d620d7c2cf1ba3aad6f3af8b7db to your computer and use it in GitHub Desktop.

Select an option

Save dayyan/fb147d620d7c2cf1ba3aad6f3af8b7db to your computer and use it in GitHub Desktop.

Revisions

  1. dayyan created this gist Feb 6, 2018.
    38 changes: 38 additions & 0 deletions micropush_fetch.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    require 'aws-sdk'

    # This assumes you have ~/.aws/credentials with a profile called production
    # granting you read access to the DynamoDB resource.
    client = Aws::DynamoDB::Client.new(region: 'us-west-2', profile: 'production')

    MC_4501 = %w(
    4fd39d51-07c4-4b26-b5e6-e3f486017580
    0e626b9d-6cd7-4d45-b4d6-ff5c1e1389a7
    cb57c61c-d2f6-4331-aab2-40e9af9d075a
    d963eb66-16e0-4097-8b38-7c715285869b
    5a4c7946-0758-45a7-b26f-39fb0178bffe
    62a80e4f-af6b-47cd-a7ed-b789312cc077
    788b85c0-5fe3-484c-841f-06786ddc7fad
    a1ea63ee-b29e-401b-ac1e-6a227f33c294
    21badd4a-f2ee-4acb-884b-b25b346f8dc5
    f00b752f-80b7-4dd5-b012-3bb9b79ea8c4
    37c88f78-dbd5-4056-9462-f351f3036c60
    ca565d1f-4193-4851-92df-85cd6f30128a
    )

    MC_4501.each do |z|
    begin
    response = client.query(
    table_name: "micropush-prod1-tokens",
    select: "ALL_ATTRIBUTES",
    key_condition_expression: "device_guid = :d",
    expression_attribute_values: {
    ":d" => z
    }
    )

    # Grab the first token.
    puts "#{z}, #{response.to_h[:items].first['token']}"
    rescue => e
    puts "#{z}, nil"
    end
    end