Giter Club home page Giter Club logo

cat's Introduction

Catapult™ Challenge

This project is the implementation of Catapult Challenge.

There are three parts of this challenge:

  1. Basic cat breed tagging API
  2. Rails engine for a generic tagging API
  3. A Cat Breed De Dupli-cat-or

This GitHub Repo is the implementation of the first part. It is implemented using Rails 5 API-only with RSpec test framework.

rails new Cat --api -T

Table of Contents

Versions

  • ruby v2.5
  • rails v5.1.5

Test Framework

  • gem 'rspec-rails'
  • gem 'shoulda-matchers'
  • gem 'factory_bot_rails'

JSON Template

  • gem 'jbuilder'

Requirements

Breed CRUD
  • GET /breeds return all breeds

  • POST /breeds creates a breed and its traits

    • This API receives the following attributes:
      • breed's name
      • tag_ids (ie. to select breed's traits from tag's existing records)
      • tags_attributes' trait (ie. to enter breed's trait into tag's new record)

  • GET /breeds/:breed_id returns the breed and all the tags belonging to it

  • PATCH /breeds/:breed_id

    • Similar inputs as POST /breeds API

  • DELETE /breeds/:breed_id removes the breed

Tag CRUD
  • GET /breeds/:id/tags returns tags on a breed

  • POST /breeds/:id/tags replaces tags on a breed

  • GET /tags return all tags in the system

  • GET /tags/:id return a tag

  • PATCH /tags/:id updates a tag

  • DELETE /tags/:id deletes the tag and all associations to breeds

    • apply dependent: :destroy

Breed & Tag Stats
  • GET /breeds/stats retrieves statistics about all breeds

  • GET /tags/stats retrieves statistics about all tags

Others
  • When it comes to tags of deleted breeds, please work out a way to ensure there aren't orphaned tags left in the system that can't be deleted.

    • use dependent: :destroy in model association

    • example:

      has_many :tags, through: :taggings, dependent: :destroy

  • n+1 is bad

    • use includes association when querying database.
    • example:
    def set_breed
      @breed = Breed.includes(:tags).find(params[:id])
    end
    
  • If you've written tests, we can see that all of the tests pass.

Future Improvements

Complete part 2 and 3 of this challenge.

cat's People

Contributors

swaption2009 avatar

Watchers

 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.