Tuesday, June 16, 2009

Update: News Feed and Survey Modules

Because surveys need to be ready for the upcoming midterms, my attention has been shifted back towards surveys, with three tasks I'm working on:

- Getting survey taking permissions working. (This is complete, but needs some more testing)

- Complete seed_db to include projects, students, and mentors (to make testing surveys much easier)

- Multiple-project support. For mentors who are overseeing more than one project, the handler needs to be updated to redirect to the correct form when a mentor selects a different project.

- Notifications. If you haven't completed your survey yet, you should be pestered until you do! This could involve a notification (or an update to the program newsfeed) but will require e-mail updates, since that's the most guaranteed way of getting someone's attention.

For the news feed module, I'm excited to be working on a demonstration PubSub support. This is fairly low-priority, but it will be nice to have built-in support for real-time applications like chat.

Statistic Module update

I am sorry for a fewer number of my commits for the last couple of days. As I wrote, I was quite busy with some other things for some time, but I also worked on Melange related stuff.

First of all, I added service for a few more statistics. They are also quite simple, but I did this boring job to match all countries with thier continents. Of course I am still in dilema about some countries - to which continent they actually belong. The most importatnt are Russia and Turkey, but for now I assigned them to Europe.

The most important thing that I did for the last week was to find a way how to deal with stats that does not belong to a particular program.
Basically, we can divide all kind of stats that we already have into two types: stats that depend on data from one program and global stats that get data from various programs. Anyway, each models that is a subclass of Linkable has attributes like link_id, scope and scope_path. For most existing models (or I can say, for all models that I checked) scope is well-defined. For example, we know that a scope for a program is sponsor or a scope for a student project is organization. However, for statistics it would be better if the scope could be determined dynamically (depending whether the statistic is global or not). So, it took some time and several attempts before I came up with a good (IMHO:) solution.

I will try to explain the final solution. First of all, it is a compromise in some way. It does not have any dynamic scope assigment, because I have to admit that I do not know how to do it. I mean it could be possible, but I think it would require an awful lot of new code and it would be like reinventing the wheel. Therefore, each statistic is still defined for a particular program, but there is a new property in statistic model: access_for_other_programs. It may have one of three possible values: invisible, visible or collectable. If a statistic is marked as invisible, it is local for a program in scope - on other programs have access to it. For statistics that should be global, there are the two other options. Visible means that a statistic which is defined for a certain program may be also read-only accessed by other programs, while collectable stats may be also collected by other program administrators.

I will update statistic module wiki page with description of those changes by tomorrow.

Monday, June 15, 2009

GSoC09: Statistics module 2nd "weekly report"

It's been about 10 days since my last post, but since I've posted my first weekly report late, I waited for Monday to write another post, so I'm sync with the others too :)
These days have been quite busy on refining JavaScript architecture for the stats module, and, in the meantime, in drawing a design that could be useful for the overall Melange project's JavaScript layer.
First of all, I've watched an interesting Best Practise in Javascript Library Design video linked by a John Resig's blog post, then I've spent some time on studying or improving my knowledge about best JavaScript practises like:
Then I've integrated in the statistics branch repository the following tools (with scripts), together with example code:
  • jsLint, testing it against some of my example code

I've integrated a slightly modified source code of the jsLint rhino version, to be compliant with the following options of the online version.

  • JSDocToolkit: it's been a little bit difficult to explain in JSDoc syntax the architecture, but finally I came up with something sensible :)

Clicking on the name of the Javascript file, you can know which lines are actually covered by the tests and how many times they have been called

  • Shrinksafe, to minify our Javascript code before releasing. I've also put some effort on using, for example, JSMin and Packer, and I've found the latter being the most efficient, also trying packing some example code using this wonderful online compressor rater

However, Packer produces a really unreadable code, acting also as a sort of obfuscator, something that probably we don't want to have. Furthermore, Shrinksafe doesn't delete new lines (which can be harmful if we forget to add a semicolon at the end of a line of code), is a little bit more "conservative" and behaves pretty good as well

After committed all these stuff, from Tuesday to Thursday I've attended the wonderful iQ Boot Camp 2009 event here in Dublin. I will never have enough words to describe how thankful I am to iQ Content for giving me the opportunity to attend it.

On Friday I've met with James Crook: we had a great afternoon together, and talked a lot about Melange and a rough architecture for the Python side to support what will be useful to accomplish Javascript frontend tasks.

On Saturday and Sunday I've committed some code to start the melange.graph.chart package (improving tests and adding jLinq code to the repository, too), which will behave as a layer to play with Google Visualization API (also starting to write code to integrate the new Google Ajax API, and, in particular, its dynamic loading, something we will need to integrate according also to Melange issue 634).

To do that, I've used some OOP inheritance, studying some articles (1,2,3). I've also found an interesting jQuery inheritance plugin, but I decided not to go with it for the moment, as it seems to me a sort of constraint more than an opportunity. I will test it later (perhaps this week), and eventually I'll change my mind :)

Furthermore, I've found an interesting site, AjaxPatterns, in which I've found informations about JSON Frameworks and Browser Side Templating, which will be really a must-have for us. I've not yet explored them into depth, but I'll decide with the community which one between JsonML, Ajax Pages, Pure and Two Birds will fit our needs better.

Last but not least, I've updated JavascriptRefactoring and JavaScriptStyleGuide Melange wiki pages according to what I've found throughout these 10 days.