Skip to content

Commit

Permalink
Adding sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush-Agnihotri committed Sep 24, 2024
1 parent 99f2388 commit b88d4b7
Show file tree
Hide file tree
Showing 35 changed files with 37 additions and 37 deletions.
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
repos:
# Updates all subsequent hooks
- repo: https://gitlab.com/vojko.pribudic.foss/pre-commit-update
rev: v0.5.1
hooks:
- id: pre-commit-update

# Linter hook
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.7
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

# Formatter hook
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.8.0
hooks:
- id: black

# Static code analysis hook
- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
hooks:
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ coreapi==2.3.3
coreschema==0.0.4
distlib==0.3.8
Django==4.0
django-rest-swagger==2.2.0
djangorestframework==3.13.1
drf-yasg==1.21.7
filelock==3.15.4
Expand Down Expand Up @@ -42,11 +43,12 @@ PyYAML==6.0.2
requests==2.26.0
requests-oauthlib==1.3.0
rsa==4.8
sentry-sdk==2.14.0
simplejson==3.19.3
six==1.16.0
sqlparse==0.4.2
tomli==1.2.3
typing_extensions==4.0.1
uritemplate==4.1.1
urllib3==1.26.7
urllib3==2.2.3
virtualenv==20.26.3
1 change: 0 additions & 1 deletion src/category/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion src/category/migrations/0002_alter_category_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("category", "0001_initial"),
]
Expand Down
1 change: 1 addition & 0 deletions src/eatery/controllers/update_eatery.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def upload_image(self, image):
"bucket": os.environ["IMAGE_BUCKET"],
"image": f"data:image/{extension};base64,{b64_encoded_image}",
},
timeout=10,
)

try:
Expand Down
1 change: 0 additions & 1 deletion src/eatery/datatype/EateryAlert.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class EateryAlert:

def __init__(
self, id: int, description: str, start_timestamp: int, end_timestamp: int
):
Expand Down
1 change: 0 additions & 1 deletion src/eatery/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = []
Expand Down
1 change: 0 additions & 1 deletion src/eatery/migrations/0002_alter_eatery_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("eatery", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion src/eatery/migrations/0003_alter_eatery_image_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("eatery", "0002_alter_eatery_id"),
]
Expand Down
1 change: 0 additions & 1 deletion src/eatery/migrations/0004_alter_eatery_campus_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("eatery", "0003_alter_eatery_image_url"),
]
Expand Down
1 change: 0 additions & 1 deletion src/eatery/migrations/0005_alter_eatery_campus_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("eatery", "0004_alter_eatery_campus_area"),
]
Expand Down
1 change: 0 additions & 1 deletion src/eatery/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class EateryPermission(permissions.BasePermission):

def has_permission(self, request, view):
if view.action in ["list", "retrieve"]:
return True
Expand Down
12 changes: 6 additions & 6 deletions src/eatery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def get_object(self):
queryset = self.filter_queryset(self.get_queryset())
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field

assert lookup_url_kwarg in self.kwargs, (
"Expected view %s to be called with a URL keyword argument "
'named "%s". Fix your URL conf, or set the `.lookup_field` '
"attribute on the view correctly."
% (self.__class__.__name__, lookup_url_kwarg)
)
# assert lookup_url_kwarg in self.kwargs, (
# "Expected view %s to be called with a URL keyword argument "
# 'named "%s". Fix your URL conf, or set the `.lookup_field` '
# "attribute on the view correctly."
# % (self.__class__.__name__, lookup_url_kwarg)
# )
# Uses the lookup_field attribute, which defaults to `pk`
filter_kwargs = {self.lookup_field: self.kwargs[lookup_url_kwarg]}
obj = get_object_or_404(queryset, **filter_kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def handle(self, *args, **kwargs):

def get_json(self):
try:
response = requests.get(CORNELL_DINING_URL)
response = requests.get(CORNELL_DINING_URL, timeout=10)
except Exception as e:
raise e
if response.status_code <= 400:
Expand Down
12 changes: 12 additions & 0 deletions src/eatery_blue_backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@

import os
from pathlib import Path
import sentry_sdk

sentry_sdk.init(
dsn="https://0f2451bfd9bf84c1858cf7319bd51425@o4507365244010496.ingest.us.sentry.io/4508008440856576",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
)

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down
1 change: 1 addition & 0 deletions src/eatery_blue_backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
permission_classes=(permissions.AllowAny,),
)


urlpatterns = [
path("admin/", admin.site.urls),
path("eatery/", include("eatery.urls")),
Expand Down
2 changes: 1 addition & 1 deletion src/event/controllers/update_models/CornellDiningEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, eatery_id: EateryID, cache):
def __call__(self, *args, **kwargs) -> list[Eatery]:
if "eateries" not in self.cache:
try:
response = requests.get(CORNELL_DINING_URL).json()
response = requests.get(CORNELL_DINING_URL, timeout=10).json()
except Exception as e:
raise e
if response["status"] == "success":
Expand Down
2 changes: 1 addition & 1 deletion src/event/controllers/update_models/CornellDiningNow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class CornellDiningNow(DfgNode):
def __call__(self, *args, **kwargs) -> list[Eatery]:
try:
response = requests.get(CORNELL_DINING_URL).json()
response = requests.get(CORNELL_DINING_URL, timeout=10).json()

except Exception as e:
raise e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, eatery_id: EateryID, cache):
def __call__(self, *args, **kwargs) -> list[Eatery]:
if "eateries" not in self.cache:
try:
response = requests.get(CORNELL_DINING_URL).json()
response = requests.get(CORNELL_DINING_URL, timeout=10).json()
except Exception as e:
raise e
if response["status"] == "success":
Expand Down
1 change: 0 additions & 1 deletion src/event/datatype/Menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class Menu:

def __init__(self, categories: list[MenuCategory]):
self.categories = categories

Expand Down
1 change: 0 additions & 1 deletion src/event/datatype/MenuCategory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class MenuCategory:

def __init__(self, category: str, items: list[MenuItem]):
self.category = category
self.items = items
Expand Down
1 change: 0 additions & 1 deletion src/event/datatype/MenuItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class MenuItem:

def __init__(
self,
name: str,
Expand Down
1 change: 0 additions & 1 deletion src/event/datatype/MenuItemSection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class MenuItemSection:

def __init__(self, name: str, subitems: list[MenuSubItem]):
self.name = name
self.subitems = subitems
Expand Down
1 change: 0 additions & 1 deletion src/event/datatype/MenuSubItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class MenuSubItem:

def __init__(
self, name: str, total_price: Optional[float], additional_price: Optional[float]
):
Expand Down
1 change: 0 additions & 1 deletion src/event/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion src/event/migrations/0002_alter_event_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("event", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion src/event/migrations/0003_alter_event_event_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("event", "0002_alter_event_id"),
]
Expand Down
1 change: 0 additions & 1 deletion src/event/migrations/0004_alter_event_event_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("event", "0003_alter_event_event_description"),
]
Expand Down
2 changes: 0 additions & 2 deletions src/item/controllers/populate_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def __init__(self):
self = self

def generate_cafe_items(self, menu, json_eatery):

for json_item in json_eatery["diningItems"]:
category_name = json_item["category"].strip()
try:
Expand All @@ -26,7 +25,6 @@ def generate_cafe_items(self, menu, json_eatery):
def generate_dining_hall_items(self, menu, json_event, json_eatery):
json_menus = json_event["menu"]
for json_menu in json_menus:

category_name = json_menu["category"].strip()
category_id = menu[category_name]

Expand Down
1 change: 0 additions & 1 deletion src/item/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion src/item/migrations/0002_alter_item_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("item", "0001_initial"),
]
Expand Down
1 change: 1 addition & 0 deletions src/manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys

Expand Down
1 change: 0 additions & 1 deletion src/person/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion src/report/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion src/report/migrations/0002_report_netid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("report", "0001_initial"),
]
Expand Down

0 comments on commit b88d4b7

Please sign in to comment.