Getting Domino application statistics
This works with any Domino application. Basic information, file size and number of documents can be retrieved from the NotesDatabase object. For the number of documents by type, you need a view with all the documents categorized by form. For the number of authors, you need a view categorized on author and containing all the documents.
Function getMainStats()
Function getMainStats As String
On Error Goto catch
Dim s As New notessession
Dim db As notesdatabase
Dim out As New stringbuffer(50)
Set db=s.CurrentDatabase
out.add |<table>|
out.add getRow(|File size: |, Format(db.Size/1000^2, "0.00") & | MB|)
out.add getRow(|Number of documents: |, db.AllDocuments.count)
out.add getRow(|Number of users: |, db.GetView("myspace-recent").TopLevelEntryCount)
out.add |</table>|
out.add |<h2>Documents by type</h2>|
out.add getCategoryStats(db.GetView("vAll"))
out.add |<h2>Documents by user</h2>|
out.add getCategoryStats(db.GetView("myspace-recent"))
getMainStats=out.collapse(NEWLINE)
Goto finally
catch:
getMainStats="Error " & Err & " in getMainStats, line " & Erl & ": " & Error$
Resume finally
finally:
End Function
Function getCategoryStats()
This function gives a table with the number of documents for all first level categories of a categorized view.
Function getCategoryStats(view As notesview)As String
On Error Goto catch
Dim nav As NotesViewNavigator
Dim entry As notesviewentry
Dim out As New stringbuffer(50)
out.add |<table>|
Set nav=view.CreateViewNav
Set entry=nav.GetFirst
While Not entry Is Nothing
out.add getRow(entry.ColumnValues(0) & |: | , entry.DescendantCount)
Set entry=nav.GetNextSibling(entry)
Wend
out.add |</table>|
getCategoryStats=out.collapse(NEWLINE)
Goto finally
catch:
getCategoryStats="Error " & Err & " in getMainStats, line " & Erl & ": " & Error$
Resume finally
finally:
End Function
Function getRow()
Just a helper function to get one row with two cells of an HTML table:
Function getRow(Byval sOne As String, Two) As String
getRow=|<tr><td class="lbl">| & sOne & |</td><td>| & Two & |</td></tr>|
End Function
Next?
These are only very basic statistics, but they can already be very useful. My objective was getting the most information out of the application without creating new elements. Percentages and charts could be added. Maybe use SVG for charts. You could also plot the number of documents created on a timeline so that you can see how the application grows over time. I'll keep you posted.
Comments
To add a comment, log in or register as new user. It's free and safe.