root/trunk/website/forums/admin/search_stats.cfm @ 5

Revision 5, 3.1 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

Line 
1<cfsetting enablecfoutputonly=true>
2<!---
3        Name         : index.cfm
4        Author       : Raymond Camden
5        Created      : January 31, 2005
6        Last Updated : August 27, 2005
7        History      : Removed mappings, use of prefix (rkc 8/27/05)
8        Purpose          :
9--->
10
11<cfset prefix = application.galleon.settings.tableprefix>
12
13<!--- will be used to generate general stats - so we get all from the last 365 days --->
14<cfset oldest = dateAdd("d", -365, now())>
15<cfquery datasource="#application.galleon.settings.dsn#" name="searchstats">
16        select  searchterms, datesearched
17        from    #prefix#search_log
18        where   datesearched > <cfqueryparam cfsqltype="cf_sql_timestamp" value="#oldest#">
19</cfquery>
20
21<!--- ineffecient - but gets around the lack of a limit op in ms access --->
22<cfquery name="latest" dbtype="query" maxrows="1">
23        select searchterms, datesearched
24        from    searchstats
25        order by datesearched desc
26</cfquery>
27
28<cfset today = createDateTime(year(now()), month(now()), day(now()), 0,0,0)>
29<cfquery name="todaysbest" dbtype="query" maxrows="1">
30        select  searchterms, count(searchterms) as score
31        from    searchstats
32        where   datesearched > <cfqueryparam cfsqltype="cf_sql_timestamp" value="#today#">
33        group by searchterms
34        order by score desc
35</cfquery>
36
37<cfset past30 = dateAdd("d", -30, now())>
38<cfquery name="thismonth" dbtype="query" maxrows="1">
39        select  searchterms, count(searchterms) as score
40        from    searchstats
41        where   datesearched > <cfqueryparam cfsqltype="cf_sql_timestamp" value="#past30#">
42        group by searchterms
43        order by score desc
44</cfquery>
45
46<cfset past365 = dateAdd("d", -365, now())>
47<cfquery name="thisyear" dbtype="query" maxrows="1">
48        select  searchterms, count(searchterms) as score
49        from    searchstats
50        where   datesearched > <cfqueryparam cfsqltype="cf_sql_timestamp" value="#past365#">
51        group by searchterms
52        order by score desc
53</cfquery>
54
55<cfquery name="top30" dbtype="query" maxrows="30">
56        select  searchterms, count(searchterms) as score
57        from    searchstats
58        group by searchterms
59        order by score desc
60</cfquery>
61       
62<cfmodule template="../tags/layout.cfm" templatename="admin" title="Galleon Search Stats">
63
64<cfoutput>
65<p>
66<table class="adminListTable" width="500">
67<tr class="adminListHeader">
68        <td colspan="2"><b>General Stats</b></td>
69</tr>
70<tr>
71        <td><b>Latest Search:</b></td>
72        <td>#latest.searchterms[1]# (#dateFormat(latest.dateSearched[1],"m/d/yy")# at #timeFormat(latest.dateSearched[1],"h:mm tt")#)</td>
73</tr>
74<tr>
75        <td><b>Most Popular (Today):</b></td>
76        <td>#todaysbest.searchterms# (#todaysbest.score#)</td>
77</tr>
78<tr>
79        <td><b>Most Popular (Past 30 Days):</b></td>
80        <td>#thismonth.searchterms# (#thismonth.score#)</td>
81</tr>
82<tr>
83        <td><b>Most Popular (Past 365 Days):</b></td>
84        <td>#thisyear.searchterms# (#thisyear.score#)</td>
85</tr>
86</table>
87</p>
88
89<p>
90<table class="adminListTable" width="500">
91<tr class="adminListHeader">
92        <td colspan="2"><b>Top 30 Search Terms</b></td>
93</tr>
94<cfloop query="top30">
95        <tr>
96                <td>#searchTerms#</td>
97                <td>#score#</td>
98        </tr>
99</cfloop>
100</table>
101</p>
102
103</cfoutput>
104
105</cfmodule>
106
107<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.