Skip to content

Commit 1c30fdd

Browse files
committed
Fetch url for dashboard corrected
1 parent a752be0 commit 1c30fdd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

static/js/dashboard.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Fetch source data for charts from Django REST API
2-
fetch('https://django-ecommerce1.herokuapp.com/tickets/api/tickets')
2+
fetch('https://django-issue-tracker-1.herokuapp.com/tickets/api/tickets')
33
.then((response) => {
44
return response.json();
55
})
66
.then((data) => {
7-
// Date parsing
7+
// Parse datetime
88
const dateFormatSpecifier = '%Y-%m-%dT%H:%M:%S.%f%Z';
99
const dateFormatParser = d3.timeParse(dateFormatSpecifier);
1010

@@ -17,7 +17,7 @@ fetch('https://django-ecommerce1.herokuapp.com/tickets/api/tickets')
1717
d.created_date_month = d3.timeMonth(d.created_date_dd);
1818
// Month
1919
d.created_date_year = d3.timeYear(d.created_date_dd);
20-
// RESOLVED DATE parsed, if resolved
20+
// If ticket status is resolved, parse RESOLVED DATE
2121
if (d.resolved_date) {
2222
// Parsed date
2323
d.resolved_date_dd = dateFormatParser(d.resolved_date);
@@ -33,6 +33,7 @@ fetch('https://django-ecommerce1.herokuapp.com/tickets/api/tickets')
3333
});
3434

3535
function drawGraphs(data) {
36+
// Crossfilter data
3637
let ndx = crossfilter(data);
3738

3839
// Pass crossfiltered data to charts
@@ -43,16 +44,18 @@ function drawGraphs(data) {
4344
drawStatusByMonthBarChart(ndx);
4445
showFilteredCount(ndx);
4546

47+
// Render all charts
4648
dc.renderAll();
4749
}
4850

49-
// Status by month
51+
// Status by Month Bar Chart
5052
function drawStatusByMonthBarChart(ndx) {
5153
let dateCreatedDim = ndx.dimension((d) => d.created_date_day);
5254
let statusGroup = dateCreatedDim
5355
.group()
5456
.reduce(reduceAdd, reduceRemove, reduceInitial);
5557

58+
// Custom reducer
5659
function reduceAdd(i, d) {
5760
i[d.status] = (i[d.status] || 0) + 1;
5861
return i;
@@ -137,14 +140,16 @@ function drawStatusRowChart(ndx) {
137140
let statusDim = ndx.dimension((d) => d.status);
138141
let statusGroup = statusDim.group();
139142

140-
// Open/Closed
143+
// Open/Closed Dimension
141144
let openClosedDim = ndx.dimension(function (d) {
142145
if (d.status == 'Resolved' || d.status == 'Cancelled') {
143146
return 'Closed';
144147
} else {
145148
return 'Open';
146149
}
147150
});
151+
152+
// Open/Closed Group
148153
let openClosedGroup = openClosedDim.group();
149154

150155
// Status Row Chart

0 commit comments

Comments
 (0)