myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [1926] branches/event_logging/app/helpers/applica


From: noreply
Subject: [myexperiment-hackers] [1926] branches/event_logging/app/helpers/application_helper.rb: News generation.
Date: Thu, 6 Nov 2008 07:06:37 -0500 (EST)

Revision
1926
Author
alekses6
Date
2008-11-06 07:06:37 -0500 (Thu, 06 Nov 2008)

Log Message

News generation. Updated helper methods so that they can process all events in the specified timeframe with no count limit.

Modified Paths

Diff

Modified: branches/event_logging/app/helpers/application_helper.rb (1925 => 1926)


--- branches/event_logging/app/helpers/application_helper.rb	2008-11-06 11:43:15 UTC (rev 1925)
+++ branches/event_logging/app/helpers/application_helper.rb	2008-11-06 12:06:37 UTC (rev 1926)
@@ -590,7 +590,9 @@
   #                           when set to "false" will pick up also all related contributors;
   # 3-4) before, after - Time objects; the news will be generated in a time slice [after..before]
   # 5) limit - number of news entries to generate
-  # 6) current_viewer - User instance, which requests to generate the news (NIL value indicates not logged in viewer)
+  #            (NIL to process all events within ["after".."before"] timeframe)
+  # 6) current_viewer - User instance, which requests to generate the news 
+  #                     (zero or NIL value indicates not logged in viewer; also a setting for RSS feeds, etc - only public events will be shown)
   def news(contributor, restrict_contributor=true, before=Time.now, after=Time.now-DEFAULT_NEWS_TIMEFRAME, limit=DEFAULT_NEWS_COUNT, current_viewer=nil)
     hash = {}
     
@@ -602,7 +604,7 @@
     
     news_array.sort! { |a, b|
       b[0] <=> a[0]
-    }[0..limit].each do |news_item|
+    }.each do |news_item|
       nearest_day = news_item[0] - (news_item[0].hour.hours + news_item[0].min.minutes + news_item[0].sec.seconds)
       
       # bugfix to 'pad out' hours and minutes which are less than ten.. eg: 3:2 --> 03:02 [am]
@@ -615,7 +617,7 @@
       end
     end
     
-    # 0th element of the hash contains sequence number of "day", sort by days when news occurred
+    # 0th element of each hash item contains sequence number of "day" --> sort by days when news occurred
     rtn = hash.sort { |a, b|
       b[0] <=> a[0]
     }
@@ -1389,6 +1391,8 @@
   
 protected
   # Produces an array of news items in a form of [timestamp, description string] from ActivityLog table.
+  # (this is a worker method, usually called from news() - therefore, the caller method has default
+  #  parameter values declared; the worker method needs to get all the parameters)
   #
   # Parameters:
   # 1) contributor - instance of a User or Network for which the news are generated;
@@ -1399,7 +1403,9 @@
   # 5) return_raw_events - used for recursive calls; when set to "true" a set of events from ActivityLog table is returned;
   #                        "false" will cause the events to be interpreted and returned as news item;
   # 6) limit - the number of news entries to produce (the lower the value, the more positive effect on performance this has)
+  #            (NIL will yield news entries interpreting ALL events in ["after".."before"] timeframe)
   # 7) current_viewer - User instance, who is currently requests news to be generated
+  #                     (zero or NIL for anonymous user - that is for public news feed: like for RSS feeds, etc)
   def contributor_news_from_log(contributor, before, after, contributor_news_only, return_raw_events, limit, current_viewer)
     
     # DEBUG

reply via email to

[Prev in Thread] Current Thread [Next in Thread]