Skip to content

Commit e3c42f5

Browse files
committed
Add times for api debug and update announcements and index
1 parent be08a6a commit e3c42f5

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

api/0.1/Generator.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const Generator = function(name, options) {
2929
this.cache = {};
3030
this.snippetCache = {};
3131
this.timeoutCache = {};
32+
this.times = {};
3233

3334
this.context = vm.createContext(this.availableFuncs());
3435
this.originalContext = [
@@ -205,6 +206,9 @@ util.inherits(Generator, EventEmitter);
205206

206207
// Receives the query which contains API, owner, and reqest data
207208
Generator.prototype.instruct = function(options, done) {
209+
this.times.instruct = {
210+
start: new Date().getTime()
211+
};
208212

209213
this.options = options || {};
210214
this.results = Number(this.options.results);
@@ -265,11 +269,16 @@ Generator.prototype.instruct = function(options, done) {
265269
], (err, results) => {
266270
// Make sure user is populated with dummy user if no real user provided
267271
this.user = this.user || {id: -1, apikey: ''};
272+
this.times.instruct = new Date().getTime() - this.times.instruct.start;
268273
done(err);
269274
});
270275
};
271276

272277
Generator.prototype.generate = function(cb) {
278+
this.times.generate = {
279+
start: new Date().getTime()
280+
};
281+
273282
this.results = this.results || 1;
274283
let output = [];
275284

@@ -718,14 +727,16 @@ Generator.prototype.updateRequires = function() {
718727
};
719728

720729
Generator.prototype.returnResults = function(err, output, cb) {
730+
this.times.generate = new Date().getTime() - this.times.generate.start;
721731
if (err === null) {
722732
let json = {
723733
results: output,
724734
info: {
725735
seed: String(this.seed),
726736
results: numeral(this.results).format('0,0'),
727737
page: numeral(this.page).format('0,0'),
728-
version: this.version
738+
version: this.version,
739+
time: this.times
729740
}
730741
};
731742

views/pages/dashboard.ejs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
You have used <span class='<%= session.user.memory > session.tier.memory ? "red" : "green" %>'><%= filesize(session.user.memory) %></span> of your <span class="green"><%= session.tier.memory === 0 ? 'unlimited' : filesize(session.tier.memory) %></span> List memory.<br>
2323

2424
You have used <span id='quotaResults' class='<%= session.tier.snippets !== 0 && session.user.snippets > session.tier.snippets ? "red" : "green" %>'><%= session.user.snippets %></span> of your <span id='tierResults' class="green"><%= session.tier.snippets === 0 ? 'unlimited' : session.tier.snippets %></span> Snippets.<br>
25-
<div class="ads">
26-
<% include ../snippets/ads %>
27-
</div>
2825
<div class="announcements">
2926
<h3>Announcements</h3>
3027
<div class="entry">
31-
<span class="title"></span></span>
32-
<p></p>
28+
<span class="title">Welcome to the Beta! - <span class="date" data-date="07-29-2016 12:28:03"></span></span>
29+
<p>Thanks for trying out the beta!<br><br>If you have any questions, feedback, etc. send an email to <a href="mailto:[email protected]" class="green">[email protected]</a>.<br><br>Thanks!<br>- Keith</p>
3330
</div>
3431
</div>
32+
<div class="ads">
33+
<% include ../snippets/ads %>
34+
</div>
3535
</div>
3636
</div>
3737
<% include ../snippets/footer %>

views/pages/index.ejs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@
1515
<section class="tryitout">
1616
<h4>Try it out!</h4>
1717
<pre id="aceEditor" name="code">let age = random.numeric(18, 65);
18-
api.age = age; // Attached to api object
18+
api.age = age; // Attached to implicit api object
1919
api.phone = phoneNum(); // Calling user defined function
2020

21+
api.favoriteColor = list([
22+
'red', 'orange', 'yellow',
23+
'green', 'blue', 'indigo',
24+
'violet'
25+
]);
26+
2127
function phoneNum(format) {
2228
format = format || "(xxx) xxx-xxxx";
2329
return String(format).split('').map(digit => {

0 commit comments

Comments
 (0)