|
RANKING THINGS AND REVIEWERSIf is common for the webmaster to want to offer his review section visitors the ability to view pages sorted by the overall rating of the things reviewed. In fact, most webmasters like to offer this as the default sorting. If you have overlooked this possibility with Review Foundry, it is there on the Configure > Build / Browse control panel. See the following configuration variables: But sorting by the overall rating comes at a price. A good number of tables need to be joined together and several columns summed and averaged in order to generate the correct ordering. As your database of review records grows, this sorting process will become slower and slower. Mind you, you may need to collect a thousand or more reviews for this to become noticeably slower (it depends a lot on your server), but slower it will become. The solution to this problem is to precompute the sorting for an entire container (category, team, or yellowpage) ahead of time, and then do a quick lookup when needed. This saves the server from having to generate the sorting from scratch every time a user requests a page. Note that the entire contain must be sorted, even though the user might be looking at just one page of dozens, or hundreds, that make up the container. The Rank control panel, new as of 2.04, allows you to precompute the ordering by overall rating for every contain in each of the 3 branches. This is done in a way similar to building pages, in that the process is done container by container, and can be carried out via the browser or via the command line. Of course, you do not need to rank containers in any branch that you are not using, so ranking can be done on a single branch, or it can be applied to all in a single RankAll process. Ranking of top reviewers is also made possible from the Rank control panel. It is recommended that you set up a cron job to be run, say, once a week, to perform the ranking. The results are stored in tables--one for each of the 3 branches, and one for top reviewers. When present, and as needed, these tables are consulted when the ordering needs to be known for a container ranked by overall rating. If these ranking tables are NOT present, the ordering is computed from scratch each time the ordering is required. Via The BrowserTo rank container pages by overall rating using your browser, go to the Rank control panel. You will see options to separately rank each of the Category, Team, and Yellow Page branches. There is an option to rank the Top Reviewer pages as well. You will also see an option to rank all 3 branches and the Top Reviewer pages, one after the other. The process is performed in steps (i.e. is staggered) just like build case. Ranking pages is much faster than building them, so it is unlikely you will suffer from any browser timeout problems. Even so, the recommended way to rank pages is to do so using a command line process, and to create an automated cron job to perform the task on a scheduled timetable. Note: As with the implementation of page building via the browser, the ranking of containers is handled via an NPH process. For NPH processes the page headers are NOT handled by the server, and instead the script produces all of its own header info. However, on some servers this is forbidden and you may see a 500-type error message produced when you try to rank containers via the browser. If that is the case, you can try toggling the nph_headers configuration variable found on the Configure > Build / Browse page. This variable allows you to switch off the NPH header management, and hand the headers generation process back over to the web server. So try this if you see an error of the form "Error 500 - Internal server error". Via The Command LineIt is recommended that if you have telnet (or SSH) access to your site, you should log in and run the ranking script via the command line. This method has the advantage that it is (somewhat) faster than the equivalent process carried out from the browser, because no CGI processing is involved. Also, ranking can take place in one (generally) long uninterrupted job--unlike ranking via the browser, where the process is split into many smaller jobs to reduce memory consumption and avoid timeout limits. But it still suffers from one drawback shared by the browser method of ranking pages--the process needs to be carried out manually. In the next section a possible solution to that problem is discussed. The command line invocations for a telnet-initiated ranking of containers can be one of the following (this assumes you are issuing the command from the Review Foundry /do/admin directory which should be directory protected): perl ./nph-admin.cgi --do=RankAll perl ./nph-admin.cgi --do=RankItem perl ./nph-admin.cgi --do=RankMember perl ./nph-admin.cgi --do=RankSupplier perl ./nph-admin.cgi --do=RankReviewer If you wish to rank all branches that are enabled in your installation, use the first command with the 'RankAll' argument. In this case, if Yellowpages, Teams, and Categories are enabled, they will be ranked, and in that order. Finally, the Top Reviewers will be determined. If you need to only rank one of the container types, use one of the other commands shown above. If you decide you want to delete the cached sortings by overall rating, add the keyword Delete to the start of a command. For example: perl ./nph-admin.cgi --do=DeleteRankItem This would have the effect of removing the ranking table associated with categories, and each time a category page is requested by a user where the ordering of items is by overall rating, that ordering will first have to be computed from scratch before the page can be rendered. For small review sections on non-busy servers this is not a real problem. On larger sites you will want to make use of the ranking tables. The easiest way to do that, is with a cron job. Via Cron JobCron jobs are perfect solution to the ranking problem. Every time you add a new thing to a container, or you set the is_validated column of an existing thing to No, you have effectively invalidated the cached ordering of things by overall rating. Also, each time you approve a new review you may be invalidating the ordering. So the rankning needs to be done fairly often, so as to be kept up to date. If it is not kept up to date, nothing bad will happen, but the sorted results might confuse visitors after a while if they are obviously incorrect. If you want to be vigilant, run a nightly cron job to sort all your containers by overall rating. Set it and forget it. If you know how to set a cron job, you'll understand the format of the cron commands shown below. In that case, edit your crontab file and add something like the following lines: 28 1 * * * perl /path/to/nph-admin.cgi --do=RankSupplier --cron=1 28 2 * * * perl /path/to/nph-admin.cgi --do=RankMember --cron=1 28 3 * * * perl /path/to/nph-admin.cgi --do=BuildItem --cron=1 28 4 * * * perl /path/to/nph-admin.cgi --do=RankReviewer --cron=1 This example, which re-ranks the Yellowpage, Team, Category, and Top Reviewer branches, every night at 1:28, 2:28, 3:28, and 4:38 A.M., respectively, the individual ranking processes each take less than an hour to complete (in fact, less than a few minutes each, most likely). Alternatively, you can elect to rank the lot, one after the other, like this: 28 2 * * * perl /path/to/nph-admin.cgi --do=RankAll --cron=1 The extra --cron=1 argument ensures that logging to the screen is switched off unless an error message needs to be output. This ensures that any email message sent to you after your cron jobs are completed remains of manageable size. If you cannot run cron jobs, try to use the telnet method instead. If that isn't possible, use the browser method as your fallback. Pulling Top Rated ThingsEven if you do not sort your containers (by default) by the overall rating, the sorting option is still there, so caching container sortings by overall rating is a good idea. In addition, you might also offer Top Rated Items, or Top Rated Suppliers at the top of each category, or yellowpage. This option was introduced in version 2.04 If you do offer one or more of the Top Rated Things it will benefit you to make use of the caching option discussed in this section. Each time you place, say, 3 Top Rated Items, on the page, the cached ordering of items by overall rating will be used to considerably shorten the amount of time required to generate the list of 3 items to be displayed. For a good deal more information about formatting Top Rated Things and similar features, see the tutorial on How To Tile Review Records. « Table of Contents | Obtain Review Foundry » Copyright © 2004 Random Mouse Software. All Rights Reserved. |