{"action":"created","comment":{"url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/comments/170702298","pull_request_review_id":99429000,"id":170702298,"diff_hunk":"@@ -1,7 +1,137 @@\n-import threading\n+\"\"\"\n+Models for Inventory Management Service\n+\n+All of the models are stored in this module\n+\n+Models\n+------\n+Entry - An Inventory Entry used in the service\n+\n+Attributes:\n+-----------\n+prod_id         (int)       - the id of the product\n+prod_name       (string)    - the name of the product\n+new_qty         (int)       - quantity of the new product\n+used_qty        (int)       - quantity of the used product\n+open_boxed_qty  (int)       - quantity of the open-boxed product\n+restock_level   (int)       - when the product total quantity reaches below this number,\n+                              an automatic restock will be trigger.\n+restock_amt     (int)       - the amount of new products restocked\n+                              when the total quantity goes under restock_level\n+\n+\"\"\"\n+\n+# import threading\n+from flask_sqlalchemy import SQLAlchemy\n \n class DataValidationError(Exception):\n-\tpass\n+    \"\"\" Used for an data validation errors when deserializing \"\"\"\n+    pass\n+\n+db = SQLAlchemy()\n+\n+class Entry(db.Model):\n+    \"\"\" A class representing an Inventory entry\"\"\"\n+\n+    app = None\n+\n+    # Table Schema\n+    prod_id = db.Column(db.Integer, primary_key=True)\n+    prod_name = db.Column(db.String(80))\n+    new_qty = db.Column(db.Integer)\n+    used_qty = db.Column(db.Integer)\n+    open_boxed_qty = db.Column(db.Integer)\n+    restock_level = db.Column(db.Integer)\n+    restock_amt = db.Column(db.Integer)\n+\n+    def __repr__(self):\n+        return repr(self.serialize())\n+\n+    def save(self):\n+        \"\"\"\n+        Saves an Entry to database,\n+        currently no duplicate detection is supported.\n+        \"\"\"\n+        db.session.add(self)\n+        db.session.commit()\n+\n+    def delete(self):\n+        \"\"\"\n+        Delete an Entry from database.\n+        \"\"\"\n+        db.session.delete(self)\n+        db.session.commit()\n+\n+    def serialize(self):\n+        \"\"\"\n+        Serialize an Entry into a dictionary.\n+        \"\"\"\n+        return {\n+            \"prod_id\": self.prod_id,\n+            \"prod_name\": self.prod_name,\n+            \"new_qty\": self.new_qty,\n+            \"used_qty\": self.used_qty,\n+            \"open_boxed_qty\": self.open_boxed_qty,\n+            \"restock_level\": self.restock_level,\n+            \"restock_amt\": self.restock_amt\n+        }\n+\n+    def deserialize(self, data, initialize_property=True):\n+        \"\"\"\n+        Deserializes an Entry from a dictionary.\n+\n+        Args:\n+            data (dict): A dictionary containing the Entry data\n+        \"\"\"\n+        if not isinstance(data, dict):\n+            raise DataValidationError('Invalid Entry: body of request contained bad or no data')\n+        # only prod_id is a must-have property\n+        try:\n+            self.prod_id = data['prod_id']\n+        except KeyError as error:\n+            raise DataValidationError('Invalid Entry: missing ' + error.args[0])\n+        except TypeError as error:\n+            raise DataValidationError('Invalid Entry: body of request contained' \\\n+                                      'bad or no data')\n+\n+        # populate Entry with data or None\n+        self.prod_name = data.get('prod_name')\n+        self.new_qty = data.get('new_qty')\n+        self.used_qty = data.get('used_qty')\n+        self.open_boxed_qty = data.get('open_boxed_qty')\n+        self.restock_level = data.get('restock_level')\n+        self.restock_amt = data.get('restock_amt')\n+\n+        if initialize_property:\n+            if self.prod_name is None:\n+                self.prod_name = 'default_prod_name'\n+            if self.new_qty is None:\n+                self.new_qty = 5\n+            if self.used_qty is None:\n+                self.used_qty = 0\n+            if self.open_boxed_qty is None:\n+                self.open_boxed_qty = 0\n+            if self.restock_level is None:\n+                self.restock_level = 5\n+            if self.restock_amt is None:\n+                self.restock_amt = 20","path":"models.py","position":null,"original_position":119,"commit_id":"f8915cb8f0d8dbd7fa1c2159ce9265b4e1b9477e","original_commit_id":"3d1476428d2cd67928edd204a10b0b337a0f1c90","user":{"login":"MingshiPeng","id":19756129,"avatar_url":"https://avatars1.githubusercontent.com/u/19756129?v=4","gravatar_id":"","url":"https://api.github.com/users/MingshiPeng","html_url":"https://github.com/MingshiPeng","followers_url":"https://api.github.com/users/MingshiPeng/followers","following_url":"https://api.github.com/users/MingshiPeng/following{/other_user}","gists_url":"https://api.github.com/users/MingshiPeng/gists{/gist_id}","starred_url":"https://api.github.com/users/MingshiPeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MingshiPeng/subscriptions","organizations_url":"https://api.github.com/users/MingshiPeng/orgs","repos_url":"https://api.github.com/users/MingshiPeng/repos","events_url":"https://api.github.com/users/MingshiPeng/events{/privacy}","received_events_url":"https://api.github.com/users/MingshiPeng/received_events","type":"User","site_admin":false},"body":"Addressed.\r\nConstants created.","created_at":"2018-02-26T19:12:14Z","updated_at":"2018-02-26T19:12:14Z","html_url":"https://github.com/NYUDevOpsInventory/inventory/pull/21#discussion_r170702298","pull_request_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/21","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/comments/170702298"},"html":{"href":"https://github.com/NYUDevOpsInventory/inventory/pull/21#discussion_r170702298"},"pull_request":{"href":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/21"}},"in_reply_to_id":170466914},"pull_request":{"url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/21","id":170925001,"html_url":"https://github.com/NYUDevOpsInventory/inventory/pull/21","diff_url":"https://github.com/NYUDevOpsInventory/inventory/pull/21.diff","patch_url":"https://github.com/NYUDevOpsInventory/inventory/pull/21.patch","issue_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues/21","number":21,"state":"open","locked":false,"title":"Database setup","user":{"login":"MingshiPeng","id":19756129,"avatar_url":"https://avatars1.githubusercontent.com/u/19756129?v=4","gravatar_id":"","url":"https://api.github.com/users/MingshiPeng","html_url":"https://github.com/MingshiPeng","followers_url":"https://api.github.com/users/MingshiPeng/followers","following_url":"https://api.github.com/users/MingshiPeng/following{/other_user}","gists_url":"https://api.github.com/users/MingshiPeng/gists{/gist_id}","starred_url":"https://api.github.com/users/MingshiPeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MingshiPeng/subscriptions","organizations_url":"https://api.github.com/users/MingshiPeng/orgs","repos_url":"https://api.github.com/users/MingshiPeng/repos","events_url":"https://api.github.com/users/MingshiPeng/events{/privacy}","received_events_url":"https://api.github.com/users/MingshiPeng/received_events","type":"User","site_admin":false},"body":"Database support added. Data model half completed.\r\n\r\nService has been tested manually with Postman.\r\nCreate inventory entry / List all inventory / List one inventory have been tested and can run successfully with the database. \r\n\r\nHowever these 3 APIs are subject to future changes since they are only set up here for testing purposes.","created_at":"2018-02-23T03:32:00Z","updated_at":"2018-02-26T19:12:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cc78e3f99c113e59aa85bb1947e4d2f3db36a01b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/21/commits","review_comments_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/21/comments","review_comment_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues/21/comments","statuses_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/statuses/f8915cb8f0d8dbd7fa1c2159ce9265b4e1b9477e","head":{"label":"NYUDevOpsInventory:database-setup","ref":"database-setup","sha":"f8915cb8f0d8dbd7fa1c2159ce9265b4e1b9477e","user":{"login":"NYUDevOpsInventory","id":36543669,"avatar_url":"https://avatars2.githubusercontent.com/u/36543669?v=4","gravatar_id":"","url":"https://api.github.com/users/NYUDevOpsInventory","html_url":"https://github.com/NYUDevOpsInventory","followers_url":"https://api.github.com/users/NYUDevOpsInventory/followers","following_url":"https://api.github.com/users/NYUDevOpsInventory/following{/other_user}","gists_url":"https://api.github.com/users/NYUDevOpsInventory/gists{/gist_id}","starred_url":"https://api.github.com/users/NYUDevOpsInventory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NYUDevOpsInventory/subscriptions","organizations_url":"https://api.github.com/users/NYUDevOpsInventory/orgs","repos_url":"https://api.github.com/users/NYUDevOpsInventory/repos","events_url":"https://api.github.com/users/NYUDevOpsInventory/events{/privacy}","received_events_url":"https://api.github.com/users/NYUDevOpsInventory/received_events","type":"Organization","site_admin":false},"repo":{"id":121772296,"name":"inventory","full_name":"NYUDevOpsInventory/inventory","owner":{"login":"NYUDevOpsInventory","id":36543669,"avatar_url":"https://avatars2.githubusercontent.com/u/36543669?v=4","gravatar_id":"","url":"https://api.github.com/users/NYUDevOpsInventory","html_url":"https://github.com/NYUDevOpsInventory","followers_url":"https://api.github.com/users/NYUDevOpsInventory/followers","following_url":"https://api.github.com/users/NYUDevOpsInventory/following{/other_user}","gists_url":"https://api.github.com/users/NYUDevOpsInventory/gists{/gist_id}","starred_url":"https://api.github.com/users/NYUDevOpsInventory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NYUDevOpsInventory/subscriptions","organizations_url":"https://api.github.com/users/NYUDevOpsInventory/orgs","repos_url":"https://api.github.com/users/NYUDevOpsInventory/repos","events_url":"https://api.github.com/users/NYUDevOpsInventory/events{/privacy}","received_events_url":"https://api.github.com/users/NYUDevOpsInventory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NYUDevOpsInventory/inventory","description":null,"fork":false,"url":"https://api.github.com/repos/NYUDevOpsInventory/inventory","forks_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/forks","keys_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/teams","hooks_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/hooks","issue_events_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues/events{/number}","events_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/events","assignees_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/assignees{/user}","branches_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/branches{/branch}","tags_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/tags","blobs_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/refs{/sha}","trees_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/statuses/{sha}","languages_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/languages","stargazers_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/stargazers","contributors_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/contributors","subscribers_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/subscribers","subscription_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/subscription","commits_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/commits{/sha}","git_commits_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/commits{/sha}","comments_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/comments{/number}","issue_comment_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues/comments{/number}","contents_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/contents/{+path}","compare_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/merges","archive_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/downloads","issues_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues{/number}","pulls_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls{/number}","milestones_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/milestones{/number}","notifications_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/labels{/name}","releases_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/releases{/id}","deployments_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/deployments","created_at":"2018-02-16T16:21:25Z","updated_at":"2018-02-22T01:28:04Z","pushed_at":"2018-02-26T19:09:17Z","git_url":"git://github.com/NYUDevOpsInventory/inventory.git","ssh_url":"git@github.com:NYUDevOpsInventory/inventory.git","clone_url":"https://github.com/NYUDevOpsInventory/inventory.git","svn_url":"https://github.com/NYUDevOpsInventory/inventory","homepage":null,"size":12,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":16,"license":null,"forks":2,"open_issues":16,"watchers":0,"default_branch":"master"}},"base":{"label":"NYUDevOpsInventory:master","ref":"master","sha":"1c1e4622d3db59263fa978b5533899a0c2767235","user":{"login":"NYUDevOpsInventory","id":36543669,"avatar_url":"https://avatars2.githubusercontent.com/u/36543669?v=4","gravatar_id":"","url":"https://api.github.com/users/NYUDevOpsInventory","html_url":"https://github.com/NYUDevOpsInventory","followers_url":"https://api.github.com/users/NYUDevOpsInventory/followers","following_url":"https://api.github.com/users/NYUDevOpsInventory/following{/other_user}","gists_url":"https://api.github.com/users/NYUDevOpsInventory/gists{/gist_id}","starred_url":"https://api.github.com/users/NYUDevOpsInventory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NYUDevOpsInventory/subscriptions","organizations_url":"https://api.github.com/users/NYUDevOpsInventory/orgs","repos_url":"https://api.github.com/users/NYUDevOpsInventory/repos","events_url":"https://api.github.com/users/NYUDevOpsInventory/events{/privacy}","received_events_url":"https://api.github.com/users/NYUDevOpsInventory/received_events","type":"Organization","site_admin":false},"repo":{"id":121772296,"name":"inventory","full_name":"NYUDevOpsInventory/inventory","owner":{"login":"NYUDevOpsInventory","id":36543669,"avatar_url":"https://avatars2.githubusercontent.com/u/36543669?v=4","gravatar_id":"","url":"https://api.github.com/users/NYUDevOpsInventory","html_url":"https://github.com/NYUDevOpsInventory","followers_url":"https://api.github.com/users/NYUDevOpsInventory/followers","following_url":"https://api.github.com/users/NYUDevOpsInventory/following{/other_user}","gists_url":"https://api.github.com/users/NYUDevOpsInventory/gists{/gist_id}","starred_url":"https://api.github.com/users/NYUDevOpsInventory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NYUDevOpsInventory/subscriptions","organizations_url":"https://api.github.com/users/NYUDevOpsInventory/orgs","repos_url":"https://api.github.com/users/NYUDevOpsInventory/repos","events_url":"https://api.github.com/users/NYUDevOpsInventory/events{/privacy}","received_events_url":"https://api.github.com/users/NYUDevOpsInventory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NYUDevOpsInventory/inventory","description":null,"fork":false,"url":"https://api.github.com/repos/NYUDevOpsInventory/inventory","forks_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/forks","keys_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/teams","hooks_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/hooks","issue_events_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues/events{/number}","events_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/events","assignees_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/assignees{/user}","branches_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/branches{/branch}","tags_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/tags","blobs_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/refs{/sha}","trees_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/statuses/{sha}","languages_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/languages","stargazers_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/stargazers","contributors_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/contributors","subscribers_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/subscribers","subscription_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/subscription","commits_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/commits{/sha}","git_commits_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/git/commits{/sha}","comments_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/comments{/number}","issue_comment_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues/comments{/number}","contents_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/contents/{+path}","compare_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/merges","archive_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/downloads","issues_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues{/number}","pulls_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls{/number}","milestones_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/milestones{/number}","notifications_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/labels{/name}","releases_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/releases{/id}","deployments_url":"https://api.github.com/repos/NYUDevOpsInventory/inventory/deployments","created_at":"2018-02-16T16:21:25Z","updated_at":"2018-02-22T01:28:04Z","pushed_at":"2018-02-26T19:09:17Z","git_url":"git://github.com/NYUDevOpsInventory/inventory.git","ssh_url":"git@github.com:NYUDevOpsInventory/inventory.git","clone_url":"https://github.com/NYUDevOpsInventory/inventory.git","svn_url":"https://github.com/NYUDevOpsInventory/inventory","homepage":null,"size":12,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":16,"license":null,"forks":2,"open_issues":16,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/21"},"html":{"href":"https://github.com/NYUDevOpsInventory/inventory/pull/21"},"issue":{"href":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues/21"},"comments":{"href":"https://api.github.com/repos/NYUDevOpsInventory/inventory/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NYUDevOpsInventory/inventory/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/NYUDevOpsInventory/inventory/statuses/f8915cb8f0d8dbd7fa1c2159ce9265b4e1b9477e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"MingshiPeng"}}