From kde-active Fri Sep 27 21:18:24 2013 From: "Aaron J. Seigo" Date: Fri, 27 Sep 2013 21:18:24 +0000 To: kde-active Subject: Re: Review Request 112965: add asset/forum/:assetId Message-Id: <20130927211824.20446.24428 () vidsolbach ! de> X-MARC-Message: https://marc.info/?l=kde-active&m=138031672514365 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============9198128839460016028==" --===============9198128839460016028== Content-Type: multipart/alternative; boundary="===============1858408595069780174==" --===============1858408595069780174== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: http://git.reviewboard.kde.org/r/112965/#review40922 ----------------------------------------------------------- > Probably something is wrong here. It takes 3 seconds indeed; have you done any profiling to see where the time is being used? server/lib/db/forum.js externalUrl; incorrect. server/lib/db/forum.js why push the topics here, just to pull them out again one-by-one later in findPost? that seems extremely inefficient. is there any reason why you can't simply fetch the post for the topic right here? server/lib/db/forum.js why does it error if you run out of items in the array? it seems to me that this is a valid result: more posts were requested than exist, but that's not an error server/lib/db/forum.js externalUrl is wrong; bodega and discourse are not external to each other. this will cause the request to exit the local network and come back in through e.g.the load ballancer server/lib/db/forum.js externalUrl is wrong; bodega and discourse are not external to each other. this will cause the request to exit the local network and come back in through e.g.the load ballancer server/lib/utils.js this is only used in forum.js, so put it there. util.js is for things that are used in more than one place. - Aaron J. Seigo On Sept. 27, 2013, 11:05 a.m., Giorgos Tsiapaliokas wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > http://git.reviewboard.kde.org/r/112965/ > ----------------------------------------------------------- > > (Updated Sept. 27, 2013, 11:05 a.m.) > > > Review request for Bodega. > > > Description > ------- > > Add a new route which returns the messages from the forum. > The json looks like this > > { > "authStatus": true, > "device": "KDE-1", > "store": "KDE-1", > "points": 10000, > "success": true, > "topics": [ > { > "title": "Foo bar linux12342425", > "message": "

foo bar linux123423235235235

" > }, > { > "title": "Foo bar linux123424566", > "message": "

foo bar linux1234578896666

" > }, > { > "title": "Foo bar linux1234245", > "message": "

foo bar linux12342245

" > }, > { > "title": "Foo bar linux1234", > "message": "

foo bar linux1234566

" > }, > { > "title": "Foo bar ioanna maria 1foo bar ioanna maria 1adsasd", > "message": "

88971238912389()(()DAS()A*(DS()ADS(()ADS908foo bar ioanna maria 1foo bar ioanna maria 1foo bar ioanna maria 1foo bar ioanna maria 1

" > } > ] > } > > > Diffs > ----- > > server/doc/bodega.json 4efa14e > server/lib/bodegadb.js 6d0c367 > server/lib/db/forum.js PRE-CREATION > server/lib/utils.js e95b6ba > server/routes.js f0be1b4 > server/test/forum.js PRE-CREATION > > Diff: http://git.reviewboard.kde.org/r/112965/diff/ > > > Testing > ------- > > $ make test/forum > ./node_modules/.bin/mocha test/forum.js --reporter spec > WARNING: Setting up server with no ssl! > Bodega server listening on localhost:3001 in devel mode > > > Forum > Authorization > ? succeeds (75ms) > List Messages > ? should fail because the asset is invalid > ? should succeed (3313ms) <------------------------------------------------------ Probably something is wrong here. It takes 3 seconds and both bodega-server and the forum are in localhost. > I did this.timeout(15000) in order to pass the test > > 3 passing (3 seconds) > > > Thanks, > > Giorgos Tsiapaliokas > > --===============1858408595069780174== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit
This is an automatically generated e-mail. To reply, visit: http://git.reviewboard.kde.org/r/112965/

> Probably something is wrong here. It takes 3 seconds

indeed; have you done any profiling to see where the time is being used?

server/lib/db/forum.js (Diff revision 1)
51
            categoryUrl =  app.config.service.discourse.externalUrl + 'category/' + url.format(result.rows[0].categoryname+ '.json');
externalUrl; incorrect.

server/lib/db/forum.js (Diff revision 1)
102
                            json.topics.push(topic);
why push the topics here, just to pull them out again one-by-one later in findPost? that seems extremely inefficient.

is there any reason why you can't simply fetch the post for the topic right here?

server/lib/db/forum.js (Diff revision 1)
105
                        callback(err);
why does it error if you run out of items in the array? it seems to me that this is a valid result: more posts were requested than exist, but that's not an error

server/lib/db/forum.js (Diff revision 1)
109
                                    (app.config.service.discourse.externalUrl + info.topic_list.more_topics_url) : null;
externalUrl is wrong; bodega and discourse are not external to each other. this will cause the request to exit the local network and come back in through e.g.the load ballancer

server/lib/db/forum.js (Diff revision 1)
128
            var url = app.config.service.discourse.externalUrl + 't/' + topic.slug + '/' + topic.id + '.json';
externalUrl is wrong; bodega and discourse are not external to each other. this will cause the request to exit the local network and come back in through e.g.the load ballancer

server/lib/utils.js (Diff revision 1)
function done(err) {
340
341
module.exports.get = function get(url, cb) {
342
    request(url, function (error, response, body) {
343
        if (!error && response.statusCode == 200) {
344
            cb(null, JSON.parse(body));
345
        } else {
346
            //FIXME
347
            cb(error, null)
348
            console.log(error);
349
        }
350
    });
351
};
352
this is only used in forum.js, so put it there. util.js is for things that are used in more than one place.

- Aaron J.


On September 27th, 2013, 11:05 a.m. UTC, Giorgos Tsiapaliokas wrote:

Review request for Bodega.
By Giorgos Tsiapaliokas.

Updated Sept. 27, 2013, 11:05 a.m.

Description

Add a new route which returns the messages from the forum.
The json looks like this

{
  "authStatus": true,
  "device": "KDE-1",
  "store": "KDE-1",
  "points": 10000,
  "success": true,
  "topics": [
    {
      "title": "Foo bar linux12342425",
      "message": "<p>foo bar linux123423235235235</p>"
    },
    {
      "title": "Foo bar linux123424566",
      "message": "<p>foo bar linux1234578896666</p>"
    },
    {
      "title": "Foo bar linux1234245",
      "message": "<p>foo bar linux12342245</p>"
    },
    {
      "title": "Foo bar linux1234",
      "message": "<p>foo bar linux1234566</p>"
    },
    {
      "title": "Foo bar ioanna maria 1foo bar ioanna maria 1adsasd",
      "message": "<p>88971238912389()(<em>()DAS</em>()A*(DS()<em>ADS(</em>()ADS908foo bar ioanna maria 1foo bar ioanna maria 1foo bar ioanna maria 1foo bar ioanna maria 1</p>"
    }
  ]
}

Testing

$ make test/forum
./node_modules/.bin/mocha test/forum.js --reporter spec
WARNING: Setting up server with no ssl!
Bodega server listening on localhost:3001 in devel mode


  Forum
    Authorization
      ? succeeds (75ms)
    List Messages
      ? should fail because the asset is invalid 
      ? should succeed (3313ms) <------------------------------------------------------ Probably something is wrong here. It takes 3 seconds and both bodega-server and the forum are in localhost.
                                                                                        I did this.timeout(15000) in order to pass the test

  3 passing (3 seconds)

Diffs

  • server/doc/bodega.json (4efa14e)
  • server/lib/bodegadb.js (6d0c367)
  • server/lib/db/forum.js (PRE-CREATION)
  • server/lib/utils.js (e95b6ba)
  • server/routes.js (f0be1b4)
  • server/test/forum.js (PRE-CREATION)

View Diff

--===============1858408595069780174==-- --===============9198128839460016028== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Active mailing list Active@kde.org https://mail.kde.org/mailman/listinfo/active --===============9198128839460016028==--