Class ProjectController
In: app/controllers/project_controller.rb
Parent: ApplicationController

Controller for interaction with the project data model.

Methods

Public Class methods

Determine the maximum value for the database field ‘updated_on’ by searching all data that has any impact on the rendering of the current page.

NOTE: This method assumes that the application is reading templates and content from the database, hence the last modified time of files in the filesystem is not examined.

[Source]

    # File app/controllers/project_controller.rb, line 10
10:   def self.last_modified (
11:     project_id,
12:     host_id,
13:     host_updated_on,
14:     page_updated_on
15:   )
16:     # A list of 'updated_on' values, as found during model inspection below.
17:     updated_on = []
18: 
19: 
20:     # Obtain all available content type ids for this project host.
21:     all_type_ids = ContentType.get_all_ids(project_id, host_id)
22: 
23: 
24:     # Obtain all available content group ids for this project host.
25:     all_group_ids = ContentGroup.get_all_ids(all_type_ids)
26: 
27: 
28:     # Template variables are composed, thus the maximal 'updated_on' value can
29:     # not be determined using an SQL query. In order to determine the most
30:     # recent 'updated_on' value for variables the composite model must be
31:     # examined.
32:     if (@variables)
33:       @variables.each_key {
34:         |variable|
35: 
36:         if (@variables["#{variable}"]['updated_on'])
37:           updated_on << @variables["#{variable}"]['updated_on']
38:         end
39:       }
40:     end
41: 
42: 
43:     # Collect the maximal 'updated_on' field for each model.
44:     updated_on << ContentCallback.last_modified(all_type_ids)
45:     updated_on << ContentGroup.last_modified(all_type_ids)
46:     updated_on << ContentGroupToItemMap.last_modified(all_group_ids)
47:     updated_on << ContentItemToGroupMap.last_modified(all_group_ids)
48:     updated_on << ContentItem.last_modified(all_type_ids)
49:     updated_on << host_updated_on if (host_updated_on)
50:     updated_on << page_updated_on if (page_updated_on)
51:     updated_on << Template.last_modified(host_id)
52: 
53: 
54:     # Determine the maximal 'updated_on' value for this project host.
55:     max = Time.at(0)
56:     updated_on.each { |updated| max = updated if (updated > max) }
57: 
58: 
59:     max
60:   end

[Validate]