GithubHelp home page GithubHelp logo

backend-test's Introduction

Requisites

  • Ruby 2.2 or 2.3
  • Bundler >= 1.14
  • PostgreSQL >= 9.5

Running

  1. setup.sh
  2. bundle exec rails s
  3. Open http://localhost:3000

Challenges

Please note that output doesn't have to match exactly the previous examples (seed has some randomness).

  1. We want a list of users and group belonging. Display all users, their crypted names, the amount of groups that they belong to, and the name of the groups, sorted by the amount of groups. You should do this with ActiveRecord, but it should trigger as few queries as possible. Example output:
Eva - 20VD6w7LkMKOA - 0 - []
Daphne - 20Rz52sSo/wpo - 2 - ["Frontend", "Madrid"]
Charles - 20sn5SsIlkS8E - 3 - ["Product", "Backend", "Madrid"]
Bob - 20H3bGo1QH5VQ - 3 - ["Leads", "Engine", "Madrid"]
Alice - 20EPxrR6s1g7I - 3 - ["Product", "Leads", "Madrid"]
  1. There's a competition within groups to be the one with more mapviews. Display a list of the mapviews of every user within their groups, sorted by group and mapviews (desc). This can be accomplished with a single SQL query. Example output:
Backend, Charles, 1233303
Engine, Bob, 1225498
Frontend, Daphne, 1279748
Leads, Alice, 1249250
Leads, Bob, 1225498
Madrid, Daphne, 1279748
Madrid, Alice, 1249250
Madrid, Charles, 1233303
Madrid, Bob, 1225498
Product, Alice, 1249250
Product, Charles, 1233303
  1. Extra ball: continuing from the previous task, for each group, we want to know the percentage of mapviews generated by each group member. One SQL query is all you need, and you're encouraged to use window functions.
 group   |  name   |  views  | percent_of_group_views
----------+---------+---------+-----------------------
 Backend  | Charles | 1211037 | 100.00% 
 Engine   | Bob     | 1223563 | 100.00%
 Frontend | Daphne  | 1264795 | 100.00%
 Leads    | Alice   | 1251522 | 50.56%
 Leads    | Bob     | 1223563 | 49.44%
 Madrid   | Daphne  | 1264795 | 25.55%
 Madrid   | Alice   | 1251522 | 25.28%
 Madrid   | Bob     | 1223563 | 24.71%
 Madrid   | Charles | 1211037 | 24.46%
 Product  | Alice   | 1251522 | 50.82%
 Product  | Charles | 1211037 | 49.18%

backend-test's People

Contributors

juanignaciosl avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.