Skip to content

Commit

Permalink
analytics from the new service incorporated
Browse files Browse the repository at this point in the history
  • Loading branch information
travula committed Mar 21, 2018
2 parents f01451c + 88b2658 commit 01e33da
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 55 deletions.
33 changes: 16 additions & 17 deletions src/info/analytics/usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@
<tbody>
<% _.each( target, function(i) {%>
<% if ((i.lab_name !== "None") &&
(i.analytics.nonopenedx.usage > 100) &&
(i.analytics.nonopenedx.usage !== 0)) { %>
(i.analytics.nonopenedx.usage > 100)) { %>
<% console.log(i) %>
<tr>
<td><%= (i.lab_name).toLocaleString() %></td>
<td><%= (i.analytics.nonopenedx.hits).toLocaleString() %></td>
<td><%= (i.analytics.nonopenedx.visits).toLocaleString() %></td>
<td><%= (i.analytics.nonopenedx.usage).toLocaleString() %></td>
<td><%= (i.lab_name).toLocaleString('en-IN') %></td>
<td><%= (i.analytics.nonopenedx.hits).toLocaleString('en-IN') %></td>
<td><%= (i.analytics.nonopenedx.visits).toLocaleString('en-IN') %></td>
<td><%= (i.analytics.nonopenedx.usage).toLocaleString('en-IN') %></td>
</tr>
<% } %>
<% }); %>
Expand All @@ -57,10 +56,10 @@
</thead>
<tbody>
<tr>
<td><a href="./iframe-src.html">Total Web Analytics</a></td>
<td><%= (target.analytics.nonopenedx.hits).toLocaleString() %></td>
<td><%= (target.analytics.nonopenedx.visits).toLocaleString() %></td>
<td><%= (target.analytics.nonopenedx.usage).toLocaleString() %></td>
<td>Total Web Analytics</td>
<td><%= (target.analytics.nonopenedx.hits).toLocaleString('en-IN') %></td>
<td><%= (target.analytics.nonopenedx.visits).toLocaleString('en-IN') %></td>
<td><%= (target.analytics.nonopenedx.usage).toLocaleString('en-IN') %></td>
</tr>
</tbody>
</table>
Expand All @@ -79,9 +78,9 @@
<tbody>
<tr>
<td>Total</td>
<td><%= ((target.nodal_centres)-1).toLocaleString() %></td>
<td><%= (target.workshops).toLocaleString() %></td>
<td><%= (target.usage).toLocaleString() %></td>
<td><%= ((target.nodal_centres)-1).toLocaleString('en-IN') %></td>
<td><%= (target.workshops).toLocaleString('en-IN') %></td>
<td><%= (target.usage).toLocaleString('en-IN') %></td>
</tr>
</tbody>
</table>
Expand All @@ -102,9 +101,9 @@
<% if (value != "VLEAD-IIITH"){ %>
<tr>
<td><%= value %></td>
<td><%= (key.nc_count).toLocaleString() %></td>
<td><%= (key.workshops).toLocaleString() %></td>
<td><%= (key.usage).toLocaleString() %></td>
<td><%= (key.nc_count).toLocaleString('en-IN') %></td>
<td><%= (key.workshops).toLocaleString('en-IN') %></td>
<td><%= (key.usage).toLocaleString('en-IN') %></td>
</tr>
<% } %>
<% }); %>
Expand Down Expand Up @@ -132,7 +131,7 @@
console.log("incoming Text " + jqxhr.responseText);
});

var jqxhr = $.getJSON('http://outreach.base1.vlabs.ac.in/get_nc_wise_usage', function(data) {
var jqxhr = $.getJSON('https://outreach.vlabs.ac.in/get_nc_wise_usage', function(data) {
var data = { target: data };
var template = _.template( $("#tpl-html3").text() );
$("#output4").html( template(data) );
Expand Down
48 changes: 27 additions & 21 deletions src/runtime/config.org.sample
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,48 @@
lab usage analytics.
4. *Outreach Service* : This service provides the total
workshop usage information.
5. *OpenedX* : This is a platform used to host the labs.
5. *OpenedX* : This is a platform used to host the labs.
6. Phase Length = 0 indicates to get all the labs. When
the phase length is greater that 0, indicates that
there is phase information.

#+NAME: app-config
#+BEGIN_SRC javascript
document.domain="pages.vlabs.ac.in";
// update this to base url to lds url where your lds service was running
document.domain="vlabs.ac.in";
// update this to base url to lds url where your lds service was running

var runtimeBrowserUrl = "http://localhost:8000/#orge205cd1";
var offlineEditionUrl = "http://localhost:8000/#orgaa62568";
var aboutPagesUrl = "http://localhost:8000";
var ldsUrl = "http://192.168.33.16:5000";
var instituteImagesUrl ="http://files.vlabs.ac.in/lds/images/institutes/";
var disciplineImagesUrl = "http://files.vlabs.ac.in/lds/images/disciplines/";
var labImagesUrl = "http://files.vlabs.ac.in/lds/images/labs/";
var runtimeBrowserUrl = "https://vlabs-about.vlabs.ac.in/#sec-4-1";
var offlineEditionUrl = "https://vlabs-about.vlabs.ac.in/#sec-2-1-1";
var aboutPagesUrl = "https://vlabs-about.vlabs.ac.in";
var ldsUrl = "https://lds.vlabs.ac.in";
var instituteImagesUrl = "https://s3-us-west-1.amazonaws.com/ld-service/images/institutes/";
var disciplineImagesUrl = "https://s3-us-west-1.amazonaws.com/ld-service/images/disciplines/";
var labImagesUrl = "https://s3-us-west-1.amazonaws.com/ld-service/images/new-lab-images/";
var hostedBaseForOpenEdx = "https://openedx.vlabs.ac.in";
var wsUsageUrl = "https://outreach.vlabs.ac.in/get_outreach_analytics";
var wsUsageDetailUrl = "https://outreach.vlabs.ac.in/usage";
var usageUrl = "https://analytics.vlabs.ac.in/analytics/vlabs";
var logUsageDetailUrl = "https://vlabs.ac.in/info/analytics/usage.html";

var hostedBaseForOpenEdx = "http://mybox.vlabs.ac.in";
var wsUsageUrl = "http://outreach.vlabs.ac.in/get_outreach_analytics";
var wsUsageDetailUrl = "http://outreach.virtual-labs.ac.in/usage";
var logUsageUrl = "http://stats.vlabs.ac.in/analytics";
var logUsageDetailUrl = "http://pages.vlabs.ac.in/info/analytics/usage.html";

var postServer = "http://mybox.vlabs.ac.in";
var footerUrl = "http://footer.vlabs.ac.in/footer";
var postServer = "https://openedx.vlabs.ac.in";
var footerUrl = "https://footer.vlabs.ac.in/footer";
var loginUrl = hostedBaseForOpenEdx + "/login";
var logoutUrl = hostedBaseForOpenEdx + "/logout";
var registerUrl = hostedBaseForOpenEdx + "/register";
var openEdxHosted = "test-openedx"; //this can be either "openedx" or "test-openedx" etc.
var cloudHosted = "cloud"; //this can be either "cloud" or staging etc.
var openEdxHosted = "openedx"; //this can be either "openedx" or "test-openedx" etc.
var cloudHosted = "cloud"; //this can be either "cloud" or staging etc.

//this variable can be either "openedx", "test-openedx", "cloud" or "institute"
//this variable can be either "openedx", "test-openedx", "cloud" or "institute"
var firstChoiceUrl = openEdxHosted;
var secondChoiceUrl = cloudHosted;
var thirdChoiceUrl = "institute";

var phaseLength = 1;
var phaseId = 2;

#+END_SRC


* Tangle :boilerplate:
** Configuration
#+BEGIN_SRC javascript :tangle js/app-config.js :eval no :noweb yes
Expand Down
46 changes: 29 additions & 17 deletions src/runtime/controller.org
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,13 @@ var getWsUsage = function() {
** Usage from Logs
#+name: log-usage
#+BEGIN_SRC js
var logUsage;
var logUsagePromise;
var getLogUsage = function() {
logUsage = logUsage || getJSON(usage);
return logUsage.then(function(data) {
console.log(data);
return data;
logUsagePromise = logUsagePromise || getJSON(usageUrl);
return logUsagePromise.then(function(data) {
return data;
});
}
};


#+END_SRC
Expand Down Expand Up @@ -664,7 +663,7 @@ var buildInstituteDisplayList = function(institutes) {
#+BEGIN_SRC js
var displayLabsOfDiscipline = function(discId) {
getLabsByDiscipline(discId)
.then(filterByPhase2Labs)
.then(filterLabsByPhase)
.then(buildLabsDisplayList)
.then(setContentInContentDiv)
.catch(function(err) {
Expand Down Expand Up @@ -789,7 +788,7 @@ var getTheRightUrl = function(hostingInfos) {
#+BEGIN_SRC js
var displayLabsOfInstitute = function(instId) {
getLabsByInstitute(instId)
.then(filterByPhase2Labs)
.then(filterLabsByPhase)
.then(buildLabsDisplayList)
.then(setContentInContentDiv)
.catch(function(err) {
Expand All @@ -807,7 +806,7 @@ var displayLabsOfInstitute = function(instId) {
#+BEGIN_SRC js
var displayAllLabs = function() {
getLabs()
.then(filterByPhase2Labs)
.then(filterLabsByPhase)
.then(buildLabsDisplayList)
.then(setContentInContentDiv)
.catch(function(err) {
Expand All @@ -816,12 +815,24 @@ var displayAllLabs = function() {
};

#+END_SRC
* Filter Phase-2 Labs
This function filters phase2 labs (114) from list of all labs (179).
#+name: display-phase-2-labs
* Filter Labs based on Phase
The configuration provides the phase information. Based on
this configuration, the labs are filtered by the phase
they belong to. If the configuration defined by =phaseId=
says phase 2, then labs belonging to phase 2 are filtered
out.

#+name: filter-labs-by-phase
#+BEGIN_SRC js
var filterByPhase2Labs = function(labs) {
return labs.filter(function(labs) { return ((labs.phase.length == 1) && (labs.phase[0].phase_id == 2)); })
var filterLabsByPhase = function(labs) {
return labs.filter(function(labs) {
if (phaseLength == 0) {
return true;
}
else {
return ((labs.phase.length == phaseLength) && (labs.phase[0].phase_id == phaseId));
}
})
};

#+END_SRC
Expand All @@ -846,6 +857,7 @@ var displayLabsByKeyWord = function() {
.then(function(labs) {
return filterLabsByKeyWord(labs, keyword);
})
.then(filterLabsByPhase)
.then(buildLabsDisplayList)
.then(setContentInContentDiv)
.catch(function(err) {
Expand Down Expand Up @@ -1053,7 +1065,7 @@ if (window.addEventListener) {
#+name: fill-and-set-log-usage
#+BEGIN_SRC js
var displayLogUsage = function(data) {
document.getElementById("logUsageDisplay").innerText = data["analytics"]["nonopenedx"]["usage"].toLocaleString();
document.getElementById("logUsageDisplay").innerText = data["analytics"]["nonopenedx"]["usage"].toLocaleString('en-IN');
};
var showLogUsageDetailPage = function() {
displayLab(logUsageDetailUrl);
Expand All @@ -1080,7 +1092,7 @@ var fillDataAndSetEventForLogUsage = function() {
#+name: fill-and-set-ws-usage
#+BEGIN_SRC js
var displayWsUsage = function(data) {
document.getElementById("wsUsageDisplay").innerText = data["usage"].toLocaleString();
document.getElementById("wsUsageDisplay").innerText = data["usage"].toLocaleString('en-IN');
};

var showWsUsageDetailPage = function() {
Expand Down Expand Up @@ -1202,7 +1214,7 @@ var makeNewListOfLabs = function() {
<<filter-labs-by-keyword>>
<<display-labs-by-keyword>>
<<authentication>>
<<display-phase-2-labs>>
<<filter-labs-by-phase>>
//<<make-list-of-labs>>
<<log-usage>>
<<fill-and-set-log-usage>>
Expand Down

0 comments on commit 01e33da

Please sign in to comment.