Source: site.view [edit]
Function name: scoreNews
Arguments:
Description:
Page type: webl
Render function:   scoreNewsRender
Module: geneticFinance

Page source:

var num;

if Size(OPTIONALARGS) == 0 then
   num = "1"
else
   num = OPTIONALARGS[0]
end;

   var db = Wub_GetDB("newsIndex");
   var coll = Wub_GetCollection(db, "articles");

   var dbobj;
   if (num == "?") then
      dbobj = Wub_NewDBObject([. score="?" .])
   else
      dbobj = Wub_NewDBObject([. num=num .])
   end;
   var res = Wub_QueryDB(coll, dbobj, 1);

   // If didn't find what user was looking for, try going to the first element (wrap around)
   if (res == nil) or (res == []) then
      dbobj = Wub_NewDBObject([. num="1" .]);
      res = Wub_QueryDB(coll, dbobj, 1)
   end;
   
   res;