Created
December 16, 2019 12:25
-
-
Save CompuIves/c0a3b7beec5c8bb7efd26d5d64a5047d to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'net/http' | |
require 'uri' | |
require 'json' | |
uri = URI.parse("https://zaczhdbo7s-dsn.algolia.net/1/indexes/*/queries?x-algolia-agent=Algolia%20for%20JavaScript%20(3.33.0)%3B%20Browser%20(lite)%3B%20react%20(16.9.0)%3B%20react-instantsearch%20(5.7.0)%3B%20JS%20Helper%202.26.1&x-algolia-application-id=ZACZHDBO7S&x-algolia-api-key=7675b9e87ed7dd5bbf18f3e5310f92d6") | |
request = Net::HTTP::Post.new(uri) | |
request.content_type = "application/x-www-form-urlencoded" | |
request.body = JSON.dump({ | |
"requests" => [ | |
{ | |
"indexName" => "prod_sandboxes", | |
"params" => "query=&hitsPerPage=0&maxValuesPerFacet=20&page=0&highlightPreTag=%3Cais-highlight-0000000000%3E&highlightPostTag=%3C%2Fais-highlight-0000000000%3E&facets=%5B%22npm_dependencies.dependency%22%2C%22template%22%2C%22tags%22%5D&tagFilters=" | |
} | |
] | |
}) | |
req_options = { | |
use_ssl: uri.scheme == "https", | |
} | |
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| | |
http.request(request) | |
end | |
parsed_body = JSON.parse(response.body) | |
puts parsed_body["results"][0]["nbHits"].to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment