Skip to content

Commit

Permalink
feat: add price dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew4Coding committed Oct 9, 2024
1 parent 8a35696 commit 4cc66aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion event-dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
"ticket": [
{
"type": "General",
"price": 15.000
"price": 15000
}
],
"category": "Olahraga",
Expand Down
3 changes: 2 additions & 1 deletion main/management/commands/reset_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ class Command(BaseCommand):

def handle(self, *args, **kwargs):
# Delete All Event data
Event.objects.all().delete()
Event.objects.all().delete()
TicketPrice.objects.all().delete()
27 changes: 14 additions & 13 deletions main/management/commands/seed_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def handle(self, *args, **kwargs):
with open('event-dataset.json', 'r') as file:
data = json.load(file)
for row in data:
# try:
try:
category = EventCategory.LAINNYA

# Check if category exists
Expand All @@ -27,16 +27,17 @@ def handle(self, *args, **kwargs):

event.save()

# # Create ticket price
# for price in row['ticket']:
# if price is not None:
# price = TicketPrice.objects.create(
# name=price['name'],
# price=price['price'],
# event=event
# )
# price.save()
# except Exception as e:
# print('Error in row' + str(row))
# pass
# Create ticket price
if row['ticket'] is not None:
for price in row['ticket']:
if price is not None:
price = TicketPrice.objects.create(
name=price['type'],
price=price['price'],
event=event
)
price.save()
except Exception as e:
print('Error in row' + str(row))
pass

0 comments on commit 4cc66aa

Please sign in to comment.