Full stack Software Engineer
This file contains hidden or 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
| gem 'httparty' | |
| gem 'graphql' | |
| gem 'graphiql-rails' | |
| gem 'sprockets', '~> 3' |
This file contains hidden or 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
| Rails.application.routes.draw do | |
| post "/graphql", to: "graphql#execute" | |
| mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql" | |
| end |
This file contains hidden or 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
| require 'httparty' | |
| Summaries.create(id:1) | |
| def get_countries | |
| country_names = [] | |
| base_url = "https://corona.lmao.ninja/countries" | |
| request = HTTParty.get(base_url).body | |
| response = JSON.parse(request) | |
| response.each_with_index do |c, i| |
This file contains hidden or 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
| module Types | |
| class CountryType < Types::BaseObject | |
| field :id, ID, null: false # default field in our db | |
| field :country_name, String, null: false # default field in our db | |
| field :cases, Integer, null: false # from here to line 12 are auto generated fields | |
| field :cases_today, Integer, null: false | |
| field :deaths, Integer, null: false | |
| field :deaths_today, Integer, null: false | |
| field :recovered, Integer, null: false | |
| field :active, Integer, null: false |
This file contains hidden or 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
| module Types | |
| class SummaryType < Types::BaseObject | |
| field :total_cases, Integer, null: false | |
| field :total_deaths, Integer, null: false | |
| field :total_recovered, Integer, null: false | |
| def request | |
| base_url = "https://corona.lmao.ninja/all" | |
| request = HTTParty.get(base_url).body |
This file contains hidden or 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
| module Types | |
| class QueryType < Types::BaseObject | |
| field :summary, [Types::SummaryType], null: false | |
| field :all_countries, [Types::CountryType], null: false | |
| field :find_country, [CountryType], null: true do | |
| argument :country_name, String, required: true | |
| end | |
| field :all_countries_limit, [CountryType], null: false do | |
| argument :per_page, Integer, required: false, default_value: 10 | |
| argument :start, Integer, required: false, default_value: 1 |
This file contains hidden or 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
| source 'https://rubygems.org' | |
| git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } | |
| gem 'byebug' | |
| gem 'httparty' | |
| gem 'nokogiri' |
This file contains hidden or 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
| require 'httparty' | |
| require 'nokogiri' | |
| require 'byebug' | |
| require 'json' | |
| def all_countries | |
| unparsed_page = HTTParty.get('https://www.worldometers.info/coronavirus/') | |
| parsed_page = Nokogiri::HTML(unparsed_page) | |
| records = [] |
This file contains hidden or 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
| def find_country_by_name(country_to_find) | |
| down_country = country_to_find.downcase | |
| all_countries.select { |country| country[:name].downcase == down_country } | |
| end | |
| puts find_country("nigeria") |
OlderNewer