Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiankun0830 committed Nov 19, 2019
1 parent f5c052d commit 14447ce
Show file tree
Hide file tree
Showing 82 changed files with 867 additions and 502 deletions.
24 changes: 24 additions & 0 deletions .idea/ISTD50043_bookReview.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/libraries/R_User_Library.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

143 changes: 143 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# python-app
# ├── Dockerfile
# └── src
# └── app.py
# └── requirements.txt

FROM python:3.6

MAINTANER [email protected]

RUN apt-get update -y && \
apt-get install -y python3-pip python3-dev

# Create app directory
WORKDIR /app

# Install app dependencies
COPY src/requirements.txt ./

RUN pip3 install -r requirements.txt

# Bundle app source
COPY src /app

EXPOSE 8080
CMD [ "python3", "app.py" ]
20 changes: 0 additions & 20 deletions analy/util.py

This file was deleted.

37 changes: 37 additions & 0 deletions application_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
echo -e "Installation script for Docker CE and nvidia-docker on Ubuntu 16+"

echo -e "Set non-interactive frontend"
echo -e "Script will run without any prompts"
export DEBIAN_FRONTEND=noninteractive

echo -e "\n###\n"
echo -e "Installing prerequisites for Docker CE"
echo -e "\n###\n"

apt-get update
apt-get remove docker docker-engine docker.io -y
apt-get install -y \
apt-utils \
apt-transport-https \
ca-certificates \
curl \
wget \
software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

echo -e "\n###\n"
echo -e "Installing Docker CE"
echo -e "Version: latest stable"
echo -e "\n###\n"

apt-get update
apt-get install docker-ce -y

docker build -t python-docker-dev .
docker run --rm -it -p 8080:8080 python-docker-dev
1 change: 0 additions & 1 deletion categories.txt

This file was deleted.

1 change: 0 additions & 1 deletion categoriesSorted.txt

This file was deleted.

12 changes: 0 additions & 12 deletions database/sql/store_user_information.sql

This file was deleted.

Binary file removed img/image-01.jpg
Binary file not shown.
Binary file removed img/image-02.jpg
Binary file not shown.
Binary file removed img/image-03.jpg
Binary file not shown.
Binary file removed img/image-04.jpg
Binary file not shown.
Binary file removed img/image-05-preview.jpg
Binary file not shown.
Binary file removed img/image-05.jpg
Binary file not shown.
Binary file removed img/image-06.jpg
Binary file not shown.
Binary file removed img/image-07.jpg
Binary file not shown.
Binary file removed img/image-08.jpg
Binary file not shown.
Binary file removed img/large-05.jpg
Binary file not shown.
9 changes: 0 additions & 9 deletions p.py

This file was deleted.

27 changes: 27 additions & 0 deletions script/mongo_script/assign_best_seller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pymongo import MongoClient

col = MongoClient("mongodb://localhost:27017/")["book_metadata"]["metadata"]
print(col.find().count())
categories = ["Mystery, Thriller & Suspense"
,"Science Fiction & Fantasy"
,"Action & Adventure"
,"Love & Romance"
,"Business & Money"
,"Health, Fitness & Dieting"
,"Professional & Technical"
,"Administration & Policy"
,"Dictionaries & Thesauruses"
,"Biographies & Memoirs"
]

def assign_rank(category):
p = {'categories': {'$elemMatch': {'$elemMatch': {'$in': [category]}}}}
documents = col.find(p).limit(10)
ids = [i['asin'] for i in documents]
ranks = list(range(1,11))
for i,rank in enumerate(ranks):
col.update_one({'asin':ids[i]},{"$set":{"salesRank":{category:rank}}})
print("Updated category "+category)

for i in categories:
assign_rank(i)
12 changes: 12 additions & 0 deletions script/mongo_script/mongo_util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use admin
db.createUser({
user: "admin",
pwd: "myadminpassword",
roles: [
{ role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" },
{ role: "dbAdminAnyDatabase", db: "admin" }
]
});
use book_log
db.createUser({user:'db_grp7_test',pwd:'1234567',roles:[{role:'readWrite',db:'book_metadata'},{role:'readWrite',db:'book_log'}]})
16 changes: 16 additions & 0 deletions script/mongo_script/set_up_mongo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
wget https://kindle-metadata.s3.amazonaws.com/kindle-metadata-after-correction.json
sudo apt-get update
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
sudo apt-get update
sudo apt install python3-pip
pip3 install pymongo
sudo apt-get install -y mongodb-org
sudo service mongod start
mongoimport --db book_metadata --collection metadata --file kindle-metadata-after-correction.json
pip3 install pymongo
python3 assign_best_sellers.py
mongo <mongo_util.js
sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mongod.conf
#sudo sed -i "s/#security:/security:\n authorization: 'enabled'/g" /etc/mongod.conf
sudo service mongod restart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ group by asin
order by rate_count desc
limit 20;

SELECT * FROM mostRated
LIMIT 10;


-- 2. highest rating score (top20)
Expand All @@ -25,3 +27,6 @@ group by asin
HAVING cnt > 4
order by avg_rating desc
limit 20;

SELECT * FROM highestAvgScore
LIMIT 10;
Loading

0 comments on commit 14447ce

Please sign in to comment.