Skip to content

Commit

Permalink
Merge pull request #1359 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
Devserv
  • Loading branch information
Aashish Vinu authored Oct 17, 2023
2 parents 04da809 + 3e74b9c commit f203830
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
7 changes: 6 additions & 1 deletion api/dashboard/campus/campus_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from utils.utils import CommonUtils, DateTimeUtils
from .dash_campus_helper import get_user_college_link
from utils.permission import CustomizePermission, JWTUtils, role_required
from utils.exception import CustomException


class CampusDetailsAPI(APIView):
Expand Down Expand Up @@ -223,5 +224,9 @@ def get(self, request):

serializer = serializers.WeeklyKarmaSerializer(user_org_link)
return CustomResponse(response=serializer.data).get_success_response()

except Exception as e:
return CustomResponse(response=str(e)).get_failure_response()
raise CustomException(
detail='somthing went wrong',
status_code=403
)
6 changes: 6 additions & 0 deletions api/dashboard/organisation/organisation_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,15 @@ def get(self, request, org_code):
"id",
"title",
"code",
affiliation_uuid=F("affiliation__id"),
affiliation_name=F("affiliation__title"),
district_uuid=F("district__id"),
district_name=F("district__name"),
zone_uuid=F("district__zone__id"),
zone_name=F("district__zone__name"),
state_uuid=F("district__zone__state__id"),
state_name=F("district__zone__state__name"),
country_uuid=F("district__zone__state__country__id"),
country_name=F("district__zone__state__country__name"),
).annotate(
karma=Sum(
Expand Down
32 changes: 24 additions & 8 deletions api/url_shortener/url_shortener_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,32 @@ def delete(self, request, url_id):
general_message="Url deleted successfully.."
).get_success_response()

class UrlAnalayticsAPI(APIView):
def get(self, request,url_id):

class UrlAnalyticsAPI(APIView):
def get(self, request, url_id):
url_shortener_object = UrlShortener.objects.get(id=url_id)
url_data = UrlShortenerTracker.objects.filter(url_shortener_id=url_shortener_object.id)

url_data = UrlShortenerTracker.objects.filter(
url_shortener_id=url_shortener_object.id
)

print(url_data)
location_data = UrlShortenerTracker.objects.filter(url_shortener=url_shortener_object) \
.values('city', 'region', 'country')

location_data = UrlShortenerTracker.objects.filter(
url_shortener=url_shortener_object
).values(
'city',
'region',
'country'
)
print(location_data)
# Browsers through which users accessed
browsers_data = UrlShortenerTracker.objects.filter(url_shortener=url_shortener_object) \
.values('browser').count()

# Browsers through which users accessed
browsers_data = UrlShortenerTracker.objects.filter(
url_shortener=url_shortener_object
).values(
'browser'
).count()

print(browsers_data)

2 changes: 1 addition & 1 deletion api/url_shortener/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
path('list/', url_shortener_view.UrlShortenerAPI.as_view()),
path('delete/<str:url_id>/', url_shortener_view.UrlShortenerAPI.as_view()),

path('get-analytics/<str:url_id>/', url_shortener_view.UrlAnalayticsAPI.as_view()),
path('get-analytics/<str:url_id>/', url_shortener_view.UrlAnalyticsAPI.as_view()),
]

0 comments on commit f203830

Please sign in to comment.