myexperiment-hackers
[Top][All Lists]
Advanced

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

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


From: noreply
Subject: [myexperiment-hackers] [1884] branches/event_logging/app/helpers/application_helper.rb: Work on news generation.
Date: Fri, 24 Oct 2008 06:42:22 -0400 (EDT)

Revision
1884
Author
alekses6
Date
2008-10-24 06:42:22 -0400 (Fri, 24 Oct 2008)

Log Message

Work on news generation. User news now also include actions that the user has undertaken as a network admin in all groups belonging to him (in an assumption that all groups have only one admin at the moment).

Modified Paths

Diff

Modified: branches/event_logging/app/helpers/application_helper.rb (1883 => 1884)


--- branches/event_logging/app/helpers/application_helper.rb	2008-10-23 12:31:57 UTC (rev 1883)
+++ branches/event_logging/app/helpers/application_helper.rb	2008-10-24 10:42:22 UTC (rev 1884)
@@ -1453,6 +1453,18 @@
     #  and subsequent sorting will be required anyway)
     events = ActivityLog.find(:all, :conditions => ["created_at > ? AND created_at < ? AND ((activity_loggable_type = ? AND activity_loggable_id = ?) OR (culprit_type = ? AND culprit_id = ?) OR (referenced_type = ? AND referenced_id = ?))", after, before, contributor.class.to_s, contributor.id, contributor.class.to_s, contributor.id, contributor.class.to_s, contributor.id])
     
+    
+    # fetch events initiated by networks (i.e. where network is a culprit) belonging to contributor;
+    # NB! this works on assumption that networks have only one admin -> therefore, events initiated by
+    # the network are the ones done by contributor as he's the admin!!
+    if contributor.class.to_s.downcase == "user"
+      contributor.networks_owned.each do |network|
+        events_as_admin = ActivityLog.find(:all, :conditions => ["created_at > ? AND created_at < ? AND (culprit_type = ? AND culprit_id = ?)", after, before, network.class.to_s, network.id]) 
+        events.concat(events_as_admin)
+      end
+    end
+    
+    
     # if any "related_contributors", get events for each
     # (can't use the "limit" parameter just yet, because events for "related_contributors" may be newer
     #  than some of the contributor in the original query)

reply via email to

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