Skip to content

Instantly share code, notes, and snippets.

@alec-c4
Last active October 23, 2022 22:06
Show Gist options
  • Save alec-c4/280f6b96485514cee5fb4c9aa9bd44a6 to your computer and use it in GitHub Desktop.
Save alec-c4/280f6b96485514cee5fb4c9aa9bd44a6 to your computer and use it in GitHub Desktop.
Code test for backend people

Code test for backend people

ordersURL - https://esi.evetech.net/latest/markets/10000002/orders/?datasource=tranquility&order_type=all&page=1 lookupNameURL - https://esi.evetech.net/latest/universe/names/?datasource=tranquility

Use the programming language you want. Use Docker to set up a minimalist environment where the code can run.

Make a GET request for the ordersURL. Then you get a JSON in return. Pick out all the IDs you find in type_ids and use them to do a POST against lookupNameURL.

Then you will get a list that, among other things, contains the name of the universe back. Pick these out and print it, sorted alphabetically.

See Swagger documentation here: https://esi.evetech.net/ui/

By running make build in this project, Docker will build an image with the dependencies it requires. make run should run the code within the image and it should print the result. If you only run make, then both build and run must be executed.

FROM ruby:latest
WORKDIR /usr/src/app/
ADD . /usr/src/app/
CMD ["ruby", "/usr/src/app/test.rb"]
.DEFAULT_GOAL := all
all: build run
build:
docker build -t test-app .
run:
docker run -it test-app
puts "Application started\n"
require 'net/http'
require 'json'
orders_url = "https://esi.evetech.net/latest/markets/10000002/orders/?datasource=tranquility&order_type=all&page=1"
lookupNameURL = "https://esi.evetech.net/latest/universe/names/?datasource=tranquility"
resp = Net::HTTP.get_response(URI.parse(orders_url))
data = JSON.load(resp.body)
type_ids = []
data.each do |result|
type_ids << result["type_id"]
end
names = []
type_ids.compact.uniq.each_slice(4) do |batch|
resp = Net::HTTP.post(URI.parse(lookupNameURL), batch.to_s)
data = JSON.load(resp.body)
data.each do |result|
names << result["name"].to_s
end
end
puts names.sort!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment