| Joacim Boive | Post date: 2007-05-22 19:02I have a forum and the client wishes that the doc count should be visible in the forum index, where all the different areas are listed.
That would mean retriving the view for each, get a coll.count, and return it. Not a very good idea...
Maybe a profiledocument that get's updated each time a user creates a document? Hmmm... But then there's chance of save/replication conflicts.
Servlet maybe? Haven't strayed much in to this area yet.
Ideas?
/J
|
| Tomas Nielsen | Post date: 2007-05-25 20:16I am not sure how many forums you have but could you do a script src that calls an openagent and have that agent return the count for that forum?
|
| Joacim Boive | Post date: 2007-05-27 10:47"That would mean retriving the view for each, get a coll.count, and return it. Not a very good idea..."

The problem isn't to get the info, it's to do it in the most efficent way.
/J
|
| Tomas Nielsen | Post date: 2007-05-27 12:10Yes, it depends on the need for performance/time you can spend developing.
But if you go with the profile solution it must be possible to do save(false,false) and have a scheduled agent readjusting the numbers every night in case there was an update that was missed. I do something similar in this forum for the post counts and last updaters.
Is the solution a heavy traffic database? The servlet solution, although fun to develop, seem a little overkill? 
But if you go with the servlet you could have a separate thread that read up the coll.count every 5-30 minutes and save the result in memory for fast delivery when the servlet is called.
Servlets that do no disk access respond so fast that you can not measure the execution time using the internal Java timer.
|
| Daniel Lehtihet | Post date: 2007-05-27 22:07How about creating a special view that displays your different sub-forums as categories. That way, you can easily use ?readviewentries and fetch the "children" attribute:
- <viewentries toplevelentries="2">
- <viewentry position="1" noteid="80000004" children="4" descendants="5" siblings="2">
- <entrydata columnnumber="0" name="key" category="true">
</viewentry>
if you really want an up-to-date snapshot that is...
regards
Daniel
|
| Fredrik Stöckel | Post date: 2007-05-28 23:03The readviewentries approach sounds like a flexible and doable solution. A Similar approach to Daniels suggestion is to include all forum-docs into one "index view" and build a simple js array containing the count for each forum in the view.
"forumIndex[\"" + forumName + "\"] = " + @DocDescendants + ";"
"Threat content as html" should be enabled and the view can be embedded in a page or similar (content-type:text/javascript" and added to the forum-index page as a regular javascript include. This is very fast.
|
| Joacim Boive | Post date: 2007-06-01 10:21Brilliant!
Both ideas are good, but I prefer the minimalistic approach so I'll go for Fredriks approach. Very simple, why didn't I think of that? :)
Thanks Guys!
/J
|