Skip to main content

Order System

This project is an OrderSystem that takes an an order and returns the correct order.

Installation with PyPI

pip install ordersystem

Extras

Clone and follow the ReadMe in this repository to see the Flask and Docker version of this application.

Usage

Ensure these environment variables are set:

MENU, COMPLIMENTARY, SINGLE_ITEM, MEAL_CATEGORY_MAPPING COURSE_CATEGORY_MAPPING, MANDATORY_COURSE

Example as below:

MENU="{\"breakfast\":{\"1\":\"Eggs\",\"2\":\"Toast\",\"3\":\"Coffee\"},\"lunch\":{\"1\":\"Sandwich\",\"2\":\"Chips\",\"3\":\"Soda\"},\"dinner\":{\"1\":\"Steak\",\"2\":\"Potatoes\",\"3\":\"Wine\",\"4\":\"Cake\"}}"

COMPLIMENTARY="{\"breakfast\":{\"main\":\"\",\"side\":\"\",\"drink\":\"\"},\"lunch\":{\"main\":\"\",\"side\":\"\",\"drink\":\"\"},\"dinner\":{\"main\":\"\",\"side\":\"\",\"drink\":\"Water\",\"dessert\":\"\"}}"

SINGLE_ITEM="{\"breakfast\":[\"1\",\"2\"],\"lunch\":[\"1\",\"3\"],\"dinner\":[\"1\",\"2\",\"3\"]}"

COURSE_CATEGORY_MAPPING="{\"main\":\"1\",\"side\":\"2\",\"drink\":\"3\",\"dessert\":\"4\"}"

MANDATORY_COURSE="{\"breakfast\":[\"main\",\"side\"],\"lunch\":[\"main\",\"side\"],\"dinner\":[\"main\",\"side\",\"dessert\"]}"

MENU references the actual menu of your ordering system. It maps the COURSE_CATEGORY_MAPPING to the actual food. COMPLIMENTARY is food items that is always included in the order such as this restaurant always want water to be included in dinner orders. SINGLE_ITEM are list of courses that could be ordered only once. In this restaurant, a Breakfast order cannot have more than 1 order of Eggs or Toast COURSE_CATEGORY_MAPPING maps the courses to the number category used by the other environment variables. Orders will be returned in the same placement as it is set in the course category. In this restaurant, the order will be returned with the main as first, the side as second and the drink as third MANDATORY_COURSE is a dictionary where the keys is the meal you want and the value is a list of the course that must be ordered with the meal. In this restaraunt, every meal must have a main and side course ordered.

To add the to the menu, first create a mapping in the COURSE_CATEGORY_MAPPING for the specific course. The set the number mapping to a food item in the Menu dictionary. Feel free to add to COMPLIMENTARY and SINGLE_ITEM if you need to make adjustments. For example, this restaurant now wants to add Crab Cakes as an appetizer to its list of options for dessert. The following environment variables will be set:

MENU="{\"breakfast\":{\"1\":\"Eggs\",\"2\":\"Toast\",\"3\":\"Coffee\"},\"lunch\":{\"1\":\"Sandwich\",\"2\":\"Chips\",\"3\":\"Soda\"},\"dinner\":{\"1\":\"Steak\",\"2\":\"Potatoes\",\"3\":\"Wine\",\"4\":\"Cake\", \"5\":\"CrabCakes\"}}"

COMPLIMENTARY="{\"breakfast\":{\"main\":\"\",\"side\":\"\",\"drink\":\"\"},\"lunch\":{\"main\":\"\",\"side\":\"\",\"drink\":\"\"},\"dinner\":{\"main\":\"\",\"side\":\"\",\"drink\":\"Water\",\"dessert\":\"\"}}"

SINGLE_ITEM="{\"breakfast\":[\"1\",\"2\"],\"lunch\":[\"1\",\"3\"],\"dinner\":[\"1\",\"2\",\"3\"]}"

COURSE_CATEGORY_MAPPING="{\"main\":\"1\",\"side\":\"2\",\"drink\":\"3\",\"dessert\":\"4\", \"appetizers\":\"5\"}"

MANDATORY_COURSE="{\"breakfast\":[\"main\",\"side\"],\"lunch\":[\"main\",\"side\"],\"dinner\":[\"main\",\"side\",\"dessert\"]}"

In your code, you can do the following.

from ordersystem.order_system import OrderSystem

ordersystem = OrderSystem()
ordersystem.get_order("Breakfast", "1,2,3")

Release files for ordersystem 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ordersystem 1.1
File Size Uploaded
ordersystem-1.1.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ordersystem 1.1
File Interpreter ABI Platform
ordersystem-1.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.0 kB

Release files / ordersystem-1.1.tar.gz

Download URL ordersystem-1.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
caf3f1fa39266c77602ac08a4b172cc8543644e53fcd7d3cc5d9f87919d286f3
BLAKE2b-256 checksum
How to use checksums
93c42f97f670928033779723e82ecd829ebab88d7ea7e361d9f7499685ce35f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / ordersystem-1.1-py3-none-any.whl

Download URL ordersystem-1.1-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f05c3e36d9d3d72f434bd7c2859cba44a6e86d62ce3316fcc1183034559ff570
BLAKE2b-256 checksum
How to use checksums
53dbc8d8bd43aa087b0267503f94048a6d832d67f09aa8c507cb6c142b44861a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page