forked from vishalanandl177/DRF-API-Logger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Total number of API calls, Chart added.
- Loading branch information
1 parent
084a9b3
commit 6649442
Showing
6 changed files
with
106 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include LICENSE | ||
include README.MD | ||
recursive-include drf_api_logger/static * | ||
recursive-include drf_api_logger/templates * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.core.management import call_command | ||
|
||
from boot_django import boot_django | ||
|
||
# call the django setup routine | ||
boot_django() | ||
|
||
call_command("collectstatic") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{% extends "admin/change_list.html" %} | ||
{% load static %} | ||
|
||
<!-- Override extrahead to add Chart.js --> | ||
{% block extrahead %} | ||
{{ block.super }} | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css" /> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.min.js"></script> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const ctx = document.getElementById('myChart').getContext('2d'); | ||
|
||
// Sample data | ||
const chartData = [ | ||
{% for item in analytics %} | ||
{"date": "{{ item.added_on__date }}", "y": {{ item.total }}}, | ||
{% endfor %} | ||
]; | ||
|
||
// Parse the dates to JS | ||
chartData.forEach((d) => { | ||
d.x = new Date(d.date); | ||
}); | ||
|
||
// Render the chart | ||
const chart = new Chart(ctx, { | ||
type: 'bar', | ||
data: { | ||
datasets: [ | ||
{ | ||
label: 'Number of API calls', | ||
data: chartData, | ||
backgroundColor: 'rgba(220,20,20,0.5)', | ||
}, | ||
], | ||
}, | ||
options: { | ||
responsive: true, | ||
scales: { | ||
xAxes: [ | ||
{ | ||
type: 'time', | ||
time: { | ||
unit: 'day', | ||
round: 'day', | ||
displayFormats: { | ||
day: 'MMM D', | ||
}, | ||
}, | ||
}, | ||
], | ||
yAxes: [ | ||
{ | ||
ticks: { | ||
beginAtZero: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
}); | ||
</script> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<!-- Render our chart --> | ||
<div style="width: 80%;"> | ||
<canvas style="margin-bottom: 30px; width: 60%; height: 50%;" id="myChart"></canvas> | ||
</div> | ||
<!-- Render the rest of the ChangeList view --> | ||
{{ block.super }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ def get_long_desc(): | |
|
||
setuptools.setup( | ||
name="drf_api_logger", | ||
version="0.0.9", | ||
version="1.0.0", | ||
author="Vishal Anand", | ||
author_email="[email protected]", | ||
description="An API Logger for your Django Rest Framework project.", | ||
|
@@ -20,6 +20,7 @@ def get_long_desc(): | |
install_requires=["djangorestframework>=3.7.4", "bleach>=3.1.5"], | ||
license='GNU General Public License v3.0', | ||
python_requires='>=3.5', | ||
include_package_data=True, | ||
classifiers=[ | ||
'Programming Language :: Python :: 3.5', | ||
'Programming Language :: Python :: 3.6', | ||
|