adding all of botlist, initial add
[botlist.git] / openbotlist / WEB-INF / jsps / stats.rb
blobaf8df0093ed100ed446021cf48b62dd63470c033
1 ##\r
2 ## Berlin Brown\r
3 ## 11/4/2006\r
4 ##\r
5 ## stats.rb\r
6 ##\r
7 include_class 'org.spirit.form.BotListPostListingForm' unless defined? BotListPostListingForm\r
8 include_class 'org.spirit.form.BotListVisitLogStatsForm' unless defined? BotListVisitLogStatsForm\r
9  \r
10 include_class 'org.spirit.bean.impl.BotListPostListing' unless defined? BotListPostListing\r
11 include_class 'org.spirit.bean.impl.BotListCityListing' unless defined? BotListCityListing\r
12 include_class 'org.spirit.util.BotListSessionManager' unless defined? BotListSessionManager\r
14 include_class('java.util.Calendar') { 'JCalendar' } unless defined? JCalendar\r
16 include_class 'org.apache.commons.logging.Log' unless defined? Log\r
17 include_class 'org.apache.commons.logging.LogFactory' unless defined? LogFactory\r
19 class ViewStatsController\r
20                 \r
21   def initialize(controller)\r
22     @controller = controller\r
23     @daohelper = @controller.userVisitLogDao\r
24     @dao_coreusers = @controller.coreUsersDao\r
25     @dao_coresettings = @controller.coreSettings\r
26   end    \r
28   #\r
29   # Generate Stats for the current week\r
30   def weekStats()\r
31     # Get the first day\r
32     curCal = JCalendar::getInstance()\r
33     curCal.add(JCalendar::DATE, -7)\r
34     weekStatsCount = @daohelper.getVisitAuditDate(curCal)\r
35     \r
36     # Extract visit stats for the last 7 days\r
37     i = -6\r
38     statMap = {}\r
39     statMapDates = {}\r
40     while i <= 0\r
41       curCal = JCalendar::getInstance()\r
42       curCal.add(JCalendar::DATE, i)\r
43       curStat = @daohelper.getVisitAuditOnDate(curCal)      \r
44       strId = "stats#{i + 6}"\r
45       statMap[strId] = curStat\r
46       statMapDates[strId] = curCal\r
47       i += 1\r
48     end\r
50     stats = BotListVisitLogStatsForm.new\r
51     stats.weekVisits = weekStatsCount\r
52     stats.weekStats = statMap\r
53     stats.weekStatsDates = statMapDates\r
54     return stats\r
55   end\r
57   #\r
58   # Generate the view\r
59   def getModel(request)      \r
60     return { }    \r
61   end\r
62   \r
63   # Processed when the form is submitted, \r
64   # see the controller 'processFormSubmission()' method\r
65   def onSubmit(request, response, form, errors)      \r
66     return form\r
67   end\r
68 end\r
70 ViewStatsController.new($controller)\r
72 ## End of Script ##\r