Skip to content

Commit

Permalink
Merge pull request #112 from TsimpDim/dev
Browse files Browse the repository at this point in the history
First version of PassBuy
  • Loading branch information
DioExtreme authored Jun 19, 2018
2 parents a35d5cc + 62599fa commit c009e61
Show file tree
Hide file tree
Showing 268 changed files with 48,069 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.scannerwork
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<img src="https://i.imgur.com/bgnXW4d.png" width="300">

![sc_badge_1](https://sonarcloud.io/api/project_badges/measure?project=passbuy&metric=alert_status) ![sc_badge_2](https://sonarcloud.io/api/project_badges/measure?project=passbuy&metric=security_rating) ![sc_badge_3](https://sonarcloud.io/api/project_badges/measure?project=passbuy&metric=ncloc)

Built by a team of students for a school project, PassBuy enables the user to find the cheapest price for his shopping list in quick and easy steps.

# Running the application

To run it locally you need to have a key for the Google Places API.

## Back-end

In the *back-end* subfolder lies content for both the database and the NodeJS API. Instructions for running or using the API can be found there as well.

## Front-end

Similarly, the *front-end* subfolder contains the Android Studio project for our application as well as an Adobe XD project file for the application's design.

## Utility Scripts

The small-scale scripts that were used, in the early stages of our application, to gather and analyze data are located in the *Utility Scripts* subfolder.

## Contributors - The Team

Μιχάλης Γεωργιάδης

Θοδωρής Παπακωνσταντίνου

Κωνσταντίνος Φράγκος

Διονύσης Σάρρος

Αλτίον Μάλκα

Χρήστος Τσιτσιρίγκας

Πασχάλης Φλώρος

Δημήτρης Χαντές

Παντελής Φιλίππου

Χρήστος Μήλιος

Δημήτρης Τσιμπιτάς
41 changes: 41 additions & 0 deletions Utility Scripts/db_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import requests
import sys
import csv
import html

def main():
'''Save product data from specific categories into a csv'''

if len(sys.argv) < 3 or len(sys.argv) > 3:
print("Usage : db_data.py <source_index> <db_index>")
sys.exit()

index = sys.argv[1]
db_index = sys.argv[2]

source = "https://www.ab.gr/click2shop/c/_INDEX_/loadMore?q=%3Apopularity&sort=popularity&pageSize=1000&pageNumber=0"

r = requests.get(source.replace('_INDEX_', index))
json_data = r.json() # Read response as json

with open("export.csv", 'w', newline='', encoding='utf-8') as csvfile:
csv_writer = csv.writer(csvfile, delimiter='|')
for product in json_data:
name = product['name']
desc = product['description']
if not desc:
desc = ""
else:
desc = html.unescape(desc)

if product.get('images'):
image = "https://www.ab.gr" + product['images'][0]['url']
else:
image = ''

csv_writer.writerow([name, desc, image, db_index])



if __name__ == "__main__":
main()
52 changes: 52 additions & 0 deletions Utility Scripts/db_prod_prices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import requests
import sys
import csv
import html
from decimal import Decimal,ROUND_HALF_UP, getcontext
import random as rnd


def main():
'''Save product data for the product_prices table into a csv'''

if len(sys.argv) < 2 or len(sys.argv) > 2:
print("Usage : db_prod_prices.py <source_index>")
sys.exit()

index = sys.argv[1]

with open("product_id.txt","a+") as idx_f:
idx_f.seek(0)
try:
prod_id = int(idx_f.readline())
except:
prod_id = 1

source = "https://www.ab.gr/click2shop/c/_INDEX_/loadMore?q=%3Apopularity&sort=popularity&pageSize=1000&pageNumber=0"

r = requests.get(source.replace('_INDEX_', index))
json_data = r.json() # Read response as json

with open("export.csv", 'w', newline='', encoding='utf-8') as csvfile:
csv_writer = csv.writer(csvfile, delimiter='|')
getcontext().prec = 3

for product in json_data:
base_price = Decimal(product["price"]["value"])

for store_id in range(1, 5): # [1,4] since we have 4 stores
variance = Decimal(rnd.uniform(-0.5, 0.5))
store_price = base_price + base_price * variance

csv_writer.writerow([prod_id, store_price, store_id])

prod_id += 1

idx_f.seek(0)
idx_f.truncate()
idx_f.write(str(prod_id))



if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions back-end/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
api/node_modules
api/.jshintrc
api/db_conf.json
Loading

0 comments on commit c009e61

Please sign in to comment.