Skip to content
Snippets Groups Projects
Commit 4b7aa540 authored by Joshua Gill's avatar Joshua Gill
Browse files

Merge branch 'develop' into 'issueThirtyNine'

Branch Update

See merge request !99
parents f2137334 bc7a9916
No related branches found
No related tags found
4 merge requests!114LoggingService service class, new method to add a log to the "Logs" table when...,!101merge,!100Fixing the data script changes made,!99Branch Update
This diff is collapsed.
...@@ -3,7 +3,9 @@ import random ...@@ -3,7 +3,9 @@ import random
import hashlib import hashlib
global current_user_id global current_user_id
current_user_id = 2 global current_stamp_id
current_stamp_id = 1
current_user_id = 1
# Where pos = position on line, total = total elements in line, fileName is the file name and concat is to remove some # Where pos = position on line, total = total elements in line, fileName is the file name and concat is to remove some
# random text from surnames.csv # random text from surnames.csv
...@@ -37,6 +39,31 @@ def createInsert(data, table, columns): ...@@ -37,6 +39,31 @@ def createInsert(data, table, columns):
tempString = 'INSERT INTO ' + table + " (" + columns + ")" + ' VALUES ' + '(' + data + ');' tempString = 'INSERT INTO ' + table + " (" + columns + ")" + ' VALUES ' + '(' + data + ');'
return tempString return tempString
def createStampBoard():
query = '10,"#ff0000","stamp.png"'
return createInsert(query, "Stamp_Boards", "Stamp_Board_Size, Stamp_Board_Colour, Stamp_Board_Icon")
def createRewards():
global current_stamp_id
rewardsArray = ['"10% off"','"5% off"','"2 for 1"','"£5 off"']
query = rewardsArray[random.randint(0,len(rewardsArray)-1)] + ',' + str(random.randint(3,10)) + ',' + str(current_stamp_id+1)
return createInsert(query, "Rewards", "Reward_Name, Reward_Stamp_Location, Stamp_Board_Id")
def linkTags(shopId):
finalArray = []
randomNo = random.randint(1,19)
tagIdArray = []
for i in range(1,20):
tagIdArray.append(i)
random.shuffle(tagIdArray)
for i in range(1, randomNo):
finalArray.append(createInsert((str(shopId) + ',' + str(tagIdArray[i])),"Shop_Tag_Links","Shop_Id, Tag_Id"))
return finalArray
# Where amount is how many names to compile, and usertype is the type of user you'd like to generate (1,2,3) # Where amount is how many names to compile, and usertype is the type of user you'd like to generate (1,2,3)
# #
# Returns a list of complete insert statements # Returns a list of complete insert statements
...@@ -66,11 +93,11 @@ def namePopulator(amount, userType): ...@@ -66,11 +93,11 @@ def namePopulator(amount, userType):
for i in range(0, amount): for i in range(0, amount):
twoFAMethod = random.randint(1, 2) twoFAMethod = random.randint(1, 2)
email = newForenames[i] + newSurnames[i] + "@email.com" email = newForenames[i] + newSurnames[i] + "@email.com"
stringInsert = '"' + newForenames[i] + '","' + newSurnames[i] + '","' + email + '","' + stdPassword + '","' + profilePic + '",' + str(twoFAMethod) stringInsert = '"' + newForenames[i].lower() + '","' + newSurnames[i].lower() + '","' + email.lower() + '","' + stdPassword + '","' + profilePic + '",' + str(twoFAMethod)
insertArray.append(createInsert(stringInsert, "Users", "User_First_Name, User_Last_Name, User_Email, User_Password, User_Profile_Picture, Two_Factor_Method_Id")) insertArray.append(createInsert(stringInsert, "Users", "User_First_Name, User_Last_Name, User_Email, User_Password, User_Profile_Picture, Two_Factor_Method_Id"))
tempAmount = current_user_id tempAmount = current_user_id
while current_user_id < (tempAmount+amount-1): while current_user_id < (tempAmount+amount):
# print(current_user_id) # print(current_user_id)
# print(current_user_id+amount) # print(current_user_id+amount)
stringInsert = str(current_user_id) + ',' + '1' + ',' + str(userType) stringInsert = str(current_user_id) + ',' + '1' + ',' + str(userType)
...@@ -115,8 +142,8 @@ def companyPopulator(amount): ...@@ -115,8 +142,8 @@ def companyPopulator(amount):
countryi = random.randint(0, len(countries)-1) countryi = random.randint(0, len(countries)-1)
stringInsert = '"' + companyNames[i] + '","' + "" + '","' + websiteArray[i] + '","' + str(earnings) + '","' + countries[countryi] + '","' + "shopPic.png" + '",' + str(random.randint(0, 1)) + ',' + str(1) stringInsert = '"' + companyNames[i] + '","' + "" + '","' + websiteArray[i].lower() + '","' + str(earnings) + '","' + countries[countryi].lower() + '","' + "shopPic.png" + '","' +"shopBanner.png" + '",' + str(random.randint(0, 1)) + ',' + str(i+2) + ',' + str(random.randint(2,7))
insertArray.append(createInsert(stringInsert, "Shops", "Shop_Name, Shop_Description, Shop_Website, Shop_Earnings, Shop_Countries, Shop_Image, Shop_Active, Stamp_Board_Id")) insertArray.append(createInsert(stringInsert, "Shops", "Shop_Name, Shop_Description, Shop_Website, Shop_Earnings, Shop_Countries, Shop_Image, Shop_Banner, Shop_Active, Stamp_Board_Id, Category_Id"))
return insertArray return insertArray
...@@ -133,6 +160,7 @@ def userWriter(f, amount, userType): ...@@ -133,6 +160,7 @@ def userWriter(f, amount, userType):
# Generates sql and writes to file # Generates sql and writes to file
def createSQLscript(): def createSQLscript():
global current_stamp_id
f = open("script.sql", "r+") f = open("script.sql", "r+")
f.truncate() f.truncate()
f.close() f.close()
...@@ -152,13 +180,30 @@ def createSQLscript(): ...@@ -152,13 +180,30 @@ def createSQLscript():
f.write("\n\n") f.write("\n\n")
# Shops
amount = int(input("How many shops would you like to generate?: ")) amount = int(input("How many shops would you like to generate?: "))
# Stamp Boards
for i in range(0,amount):
f.write(createStampBoard())
f.write("\n")
f.write(createRewards())
f.write("\n")
current_stamp_id+=1
# Shops
companies = companyPopulator(amount) companies = companyPopulator(amount)
for each in companies: for each in companies:
f.write(each) f.write(each)
f.write("\n") f.write("\n")
# Tags
tagLinkArray = []
for i in range(1, amount+1):
tagLinkArray = linkTags(i)
for i in range(0,len(tagLinkArray)):
f.write(tagLinkArray[i])
f.write("\n")
f.close() f.close()
......
...@@ -311,35 +311,22 @@ INSERT INTO Admin_Types (Admin_Type_Id, Admin_Type_Name) VALUES (1,'User'); ...@@ -311,35 +311,22 @@ INSERT INTO Admin_Types (Admin_Type_Id, Admin_Type_Name) VALUES (1,'User');
INSERT INTO Admin_Types (Admin_Type_Id, Admin_Type_Name) VALUES (2,'Business Admin'); INSERT INTO Admin_Types (Admin_Type_Id, Admin_Type_Name) VALUES (2,'Business Admin');
INSERT INTO Admin_Types (Admin_Type_Id, Admin_Type_Name) VALUES (3,'Super Admin'); INSERT INTO Admin_Types (Admin_Type_Id, Admin_Type_Name) VALUES (3,'Super Admin');
INSERT INTO Tags (Tag_Name) VALUES ('Football'); INSERT INTO Tags (Tag_Name) VALUES ('football');
INSERT INTO Tags (Tag_Name) VALUES ('Fashion'); INSERT INTO Tags (Tag_Name) VALUES ('fashion');
INSERT INTO Tags (Tag_Name) VALUES ('Electronics'); INSERT INTO Tags (Tag_Name) VALUES ('electronics');
INSERT INTO Tags (Tag_Name) VALUES ('Coffee'); INSERT INTO Tags (Tag_Name) VALUES ('coffee');
INSERT INTO Tags (Tag_Name) VALUES ('Art'); INSERT INTO Tags (Tag_Name) VALUES ('art');
INSERT INTO Tags (Tag_Name) VALUES ('Pets'); INSERT INTO Tags (Tag_Name) VALUES ('pets');
INSERT INTO Tags (Tag_Name) VALUES ('Clothes'); INSERT INTO Tags (Tag_Name) VALUES ('clothes');
INSERT INTO Tags (Tag_Name) VALUES ('Designer'); INSERT INTO Tags (Tag_Name) VALUES ('designer');
INSERT INTO Tags (Tag_Name) VALUES ('Groceries'); INSERT INTO Tags (Tag_Name) VALUES ('groceries');
INSERT INTO Tags (Tag_Name) VALUES ('Cars'); INSERT INTO Tags (Tag_Name) VALUES ('cars');
INSERT INTO Tags (Tag_Name) VALUES ('Hiking'); INSERT INTO Tags (Tag_Name) VALUES ('hiking');
INSERT INTO Tags (Tag_Name) VALUES ('Cooking'); INSERT INTO Tags (Tag_Name) VALUES ('cooking');
INSERT INTO Tags (Tag_Name) VALUES ('Furniture'); INSERT INTO Tags (Tag_Name) VALUES ('furniture');
INSERT INTO Tags (Tag_Name) VALUES ('Gaming'); INSERT INTO Tags (Tag_Name) VALUES ('gaming');
INSERT INTO Tags (Tag_Name) VALUES ('Travelling'); INSERT INTO Tags (Tag_Name) VALUES ('travelling');
INSERT INTO Tags (Tag_Name) VALUES ('Beauty'); INSERT INTO Tags (Tag_Name) VALUES ('beauty');
INSERT INTO Tags (Tag_Name) VALUES ('Eco-friendly'); INSERT INTO Tags (Tag_Name) VALUES ('eco-friendly');
INSERT INTO Tags (Tag_Name) VALUES ('Decorations'); INSERT INTO Tags (Tag_Name) VALUES ('decorations');
INSERT INTO Tags (Tag_Name) VALUES ('Photography'); INSERT INTO Tags (Tag_Name) VALUES ('photography');
INSERT INTO Events (Event_Name) VALUES ('New Account Created');
INSERT INTO Events (Event_Name) VALUES ('Failed Login');
INSERT INTO Events (Event_Name) VALUES ('Successful Login');
INSERT INTO Events (Event_Name) VALUES ('User Details Changed');
INSERT INTO Events (Event_Name) VALUES ('User Removed');
INSERT INTO Events (Event_Name) VALUES ('New Shop');
INSERT INTO Events (Event_Name) VALUES ('Deleted Shop');
INSERT INTO Events (Event_Name) VALUES ('New Favourite Business');
INSERT INTO Events (Event_Name) VALUES ('New Shop User');
INSERT INTO Events (Event_Name) VALUES ('Shop Details Changed');
INSERT INTO Events (Event_Name) VALUES ('Shop Activity Toggled');
INSERT INTO Events (Event_Name) VALUES ('Image Inserted');
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<p th:text="${reward_amount_obtained} + '/' + ${total_reward_amount}"></p> <p th:text="${reward_amount_obtained} + '/' + ${total_reward_amount}"></p>
</div> </div>
<div class="level-right"> <div class="level-right">
<a th:href="'businessDetails?shopId=' + ${shop.getShopId()}"> <a th:href="'businessDetails?shopId=' + ${shopId}">
<button class="button is-rounded"> <button class="button is-rounded">
Explore Explore
<span class="icon is-small is-left ml-1"> <span class="icon is-small is-left ml-1">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment