Advertisement
snarfblat

NQ Reporting

Jun 24th, 2014
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!--- this assumes SQL for the whole thing; replace whatever you want with Mura iterators --->
  2.  
  3. <cfset users = []>
  4. <cfset x = 0>
  5. <cfset agerange1 = 0>
  6. <cfset agerange2 = 0>
  7. <cfset male = 0>
  8. <cfset female = 0>
  9. </etc>
  10.  
  11. <!--- loop over genres --->
  12. <cfquery name="get_genres">
  13. select genreid from genres
  14. </cfquery>
  15.  
  16. <cfoutput query="get_genres">
  17.  
  18.     <cfquery name="get_shows">
  19.     select showid from shows
  20.     where genreid = #get_genres.genreid#
  21.     </cfquery> 
  22.  
  23.     <!--- loop over shows within a genre --->
  24.  
  25.     <cfoutput query="get_shows">
  26.    
  27.         <cfquery name="get_users">
  28.         select userid from subscriptions
  29.         where showid = #get_shows.showid#
  30.         </cfquery>
  31.  
  32.         <!--- loop over the users in the subscription list for each show in genre --->
  33.  
  34.         <cfoutput query="get_users">
  35.  
  36.             <cfquery name="get_user_details">
  37.             select age, dob, gender
  38.             from users
  39.             where userid = #get_users.userid#
  40.             </cfquery>
  41.  
  42.             <!--- determine gender, age group --->
  43.  
  44.             <cfoutput query="get_user_details">
  45.  
  46.                 <!--- calculate their age here based on dob --->
  47.  
  48.                 <cfif (gender is male)>
  49.  
  50.                     <cfif (age range is in first group)>
  51.                         <cfset male_agerange1 = male_agerange1 + 1>
  52.                     <cfelseif (age range in second group)>
  53.                         <cfset male_agerange2 = male_agerange2 + 1>
  54.                     </etc>
  55.  
  56.                 <cfelseif (gender is female)>
  57.  
  58.                     <cfif (age range is in first group)>
  59.                         <cfset female_agerange1 = female_agerange1 + 1>
  60.                     <cfelseif (age range in second group)>
  61.                         <cfset female_agerange2 = female_agerange2 + 1>
  62.                     </etc>
  63.  
  64.                 </cfif>
  65.  
  66.             </cfoutput>
  67.  
  68.         </cfoutput>
  69.  
  70.     </cfoutput>
  71.  
  72.     <cfset x = x + 1>
  73.     <cfset users[x] = {}>
  74.  
  75.     <cfset users[x].male_agerange1 = male_agegroup1>
  76.     <cfset users[x].male_agerange2 = male_agegroup2>
  77.     <cfset users[x].female_agerange1 = female_agerange1>
  78.     <cfset users[x].female_agerange2 = female_agerange2>
  79.     </etc>
  80.  
  81.     <cfset users[x].genre = (call to get Genre)>
  82.  
  83.     <cfset male_agerange1 = 0>
  84.     <cfset male_agerange2 = 0>
  85.     </etc>
  86.  
  87. </cfoutput>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement