Coder Social home page Coder Social logo

easy_cafe's Introduction

Easy Cafe

Live Site

A cafeteria management system built with:

  • Ruby On Rails (backend)

  • HTML, CSS, JS (frontend)

  • It supports multiple user roles like owner, clerk, customer.

  • Offline billing through Walk-IN customer account.

  • See sales report.

  • Manage section for owners and clerks for sudo functionalities.

Home

Owner Credentials

email: admin[at]admin[dot]com password: admin

Owners Can

  • Manage Users - Add, delete clerks Manage Menus
  • Manage menus - create, update, delete and choose active menus
  • Manage Orders - mark orders as delivered
  • See Sales Report - See total sales on the site so far, see user's orders and details
  • As well as anything a normal customer can do

Clerk's Credentials

email: h[at]h[dot]com password: 12345

Clerks Can

  • Manage Orders - - Manage Orders - mark orders as delivered
  • As well as anything a normal customer can do Manage Menus

Walk-In User's Credentials

email: test[at]test[dot]com password: 12345

easy_cafe's People

Contributors

jasim avatar procode2 avatar

Watchers

 avatar

easy_cafe's Issues

Code Review Feedback

  1. Order#create_order_items is the wrong place for it to sit. The method does not do anything with the current order instance. Instead it could be in OrderItem, like OrderItem#self.create_from_cart(user).

  2. OrderItem#sales_uptil_today should be using an ActiveRecord query, and not do it in Ruby land. Something like: all.sum(:menu_item_price. This will generate an SQL query which is faster to execute. If we do it in Ruby, then imagine we have 1 million entries in our order_items table. In the current approach we have to iterate over each of them - and for that we have to transport that data from the Postgres server into our Ruby process (this could be two different computers sitting in a network) - and instantiate an ActiveRecord object for each row - and then add them up. But instead if we call the SQL sum directly, then all the computation is done by the Postgres server which is very efficient at these things, and the Ruby process only gets a single summed value.

  3. I really like how you’ve done {success, error} hashes to return values. Good thinking! In proper object-oriented programming, you would make a class for this, but that’s for another day :)

  4. I also like that you’ve created model methods like self.create_user, self.create_order etc. This is the right spirit of MVC - you do all the domain related things in the model, and the controller remains very thin.

  5. MenuItem.get_item_info should use ActiveRecord objects themselves. So in Cart#create_cart you’d send it an array of ActiveRecord objects directly.

    So inCartsController line 11, which is currently:

items_info = MenuItem.get_item_info(filtered_params)

It can instead be something like:

cart_items = params[:menu_items].
              reject {|id, qty| id.blank? || qty.blank? }
cart_items = MenuItem.from_cart(cart_items)

And in MenuItem:

def from_cart(items)
items.map {|id, qty| {
  menu_item: MenuItem.find_by(id: id), 
	quantity: qty
}}    

You should be storing the id of each item in the HTML form, not name, since names cannot uniquely identify entries.

The idea here is that you can pass around ActiveRecord objects and use them to fetch additional information like price and description.You don’t have to map them into plain Ruby hashes.

  1. Remember to format all source files. If you’re using VSCode, install rufo (https://marketplace.visualstudio.com/items?itemName=jnbt.vscode-rufo) and enable “Format on Save” option in VSCode so you don’t even have to think about formatting again.

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.