Skip to content
Browse files

optimized some queries that were pulling down too much data and upgra…

…ded version to latest Grails 1.2.0 snapshot
  • Loading branch information...
1 parent 5cbb589 commit c187e0fb82cfe3953746dc40ae498426d8c046fd @graemerocher graemerocher committed
View
2 grails.org/application.properties
@@ -1,6 +1,6 @@
#Grails Metadata file
#Tue Nov 17 09:23:28 CET 2009
-app.grails.version=1.2-SNAPSHOT
+app.grails.version=1.2.0.BUILD-SNAPSHOT
app.name=site
app.servlet.version=2.4
app.version=3.2
View
22 grails.org/grails-app/controllers/org/grails/ContentController.groovy
@@ -162,14 +162,26 @@ class ContentController extends BaseWikiController {
}
def infoWikiPage = {
- def page = WikiPage.findByTitle(params.id.decodeURL())
+ def page = WikiPage.findByTitle(params.id.decodeURL(), [cache:true])
if(page) {
- def pageVersions = Version.findAllByCurrent(page)
- pageVersions = pageVersions.sort { it.number }
-
- render(template:'wikiInfo',model:[wikiPage:page, versions:pageVersions, update:params.update])
+ def pageVersions = Version.withCriteria {
+ projections {
+ distinct 'number', 'version'
+ property 'author'
+ }
+ eq 'current', page
+ order 'number', 'asc'
+ cache true
+ }
+ def first = pageVersions ? Version.findByNumberAndCurrent(pageVersions[0][0], page, [cache:true]) : null
+ def last = pageVersions ? Version.findByNumberAndCurrent(pageVersions[-1][0], page, [cache:true]) : null
+
+ render(template:'wikiInfo',model:[first:first, last:last,wikiPage:page,
+ versions:pageVersions.collect { it[0]},
+ authors:pageVersions.collect { it[1]},
+ update:params.update])
}
}
View
8 grails.org/grails-app/controllers/org/grails/downloads/DownloadController.groovy
@@ -26,19 +26,19 @@ class DownloadController {
}
def betaDownload = getCachedOr("GrailsBeta") {
- def downloads = Download.findAllBySoftwareNameAndBetaRelease('Grails', true,[max:1, order:'desc', sort:'releaseDate'])
+ def downloads = Download.findAllBySoftwareNameAndBetaRelease('Grails', true,[max:1, order:'desc', sort:'releaseDate', cache:true])
downloads ? downloads[0] : null
}
def doc = getCachedOr("Grails Documentation") {
- def docs = Download.findAllBySoftwareNameAndBetaRelease('Grails Documentation',false,[max:1, order:'desc', sort:'releaseDate'])
+ def docs = Download.findAllBySoftwareNameAndBetaRelease('Grails Documentation',false,[max:1, order:'desc', sort:'releaseDate', cache:true])
docs? docs[0] : null
}
def betaDoc = getCachedOr("GrailsBeta Documentation") {
- def docs = Download.findAllBySoftwareNameAndBetaRelease('Grails Documentation',true,[max:1, order:'desc', sort:'releaseDate'])
+ def docs = Download.findAllBySoftwareNameAndBetaRelease('Grails Documentation',true,[max:1, order:'desc', sort:'releaseDate', cache:true])
docs? docs[0] : null
}
@@ -55,7 +55,7 @@ class DownloadController {
}
def archive = {
- def downloads = Download.findAllBySoftwareName(params.id, [order:'desc', sort:'releaseDate'])
+ def downloads = Download.findAllBySoftwareName(params.id, [order:'desc', sort:'releaseDate', cache:true])
return [downloads:downloads]
}
View
33 grails.org/grails-app/controllers/org/grails/plugin/PluginController.groovy
@@ -90,39 +90,6 @@ class PluginController extends BaseWikiController {
pluginList:Plugin.list(max:10, offset: params.offset?.toInteger(), cache:true, sort:"name")]
}
- def pluginListCache
- def list = {
- def pluginMap = pluginListCache?.get("fullPluginList")?.value
- if(!pluginMap) {
- pluginMap = [:]
- Tag.list(sort:'name', cache:true).each { tag ->
- pluginMap[tag.name] = []
- def links = TagLink.findAllByTagAndType(tag, 'plugin', [cache:true])
- if(links) {
- pluginMap[tag.name] = Plugin.withCriteria {
- inList 'id', links*.tagRef
- cache true
- }
- }
- pluginMap[tag.name].sort { it.title }
- }
-
- pluginListCache.put new Element("fullPluginList", pluginMap)
- }
-
- // remove empty tags
- pluginMap = pluginMap.findAll { it.value.size() }
- def taggedIds = TagLink.withCriteria {
- eq('type', 'plugin')
- projections {
- distinct('tagRef')
- }
- cache true
- }
- pluginMap.untagged = Plugin.findAllByIdNotInList(taggedIds, [cache:true])
- render view:'listPlugins', model:[pluginMap: pluginMap]
- }
-
def show = {
def plugin = byName(params)
if (!plugin) {
View
13 grails.org/grails-app/views/content/_versionList.gsp
@@ -4,23 +4,22 @@
</g:if>
<ul>
-<g:each in="${versions}" var="v">
+<g:each in="${versions}" var="v" status="i">
<li>
<g:remoteLink update="${updateElement}"
controller="content"
action="showWikiVersion" id="${wikiPage?.title}"
- params="[number:v.number, update:updateElement]">
- Version ${v.number}</g:remoteLink> (Updated by <strong>${v.author.login}</strong>)
+ params="[number:v, update:updateElement]">
+ Version ${v}</g:remoteLink> (Updated by <strong>${authors[i].login}</strong>)
<jsec:authenticated>
- - Created: ${v.dateCreated} -
- <g:if test="${v.number != wikiPage.version}">
+ <g:if test="${v != wikiPage.version}">
<jsec:hasRole name="Administrator">
<g:remoteLink update="versions"
controller="content"
action="rollbackWikiVersion"
id="${wikiPage?.title}"
- params="[number:v.number]">Rollback to here</g:remoteLink>
+ params="[number:v]">Rollback to here</g:remoteLink>
</jsec:hasRole>
</g:if>
<g:else>Latest Version</g:else>
@@ -31,7 +30,7 @@
action="diffWikiVersion"
id="${wikiPage?.title}"
options="[method:'POST']"
- params="[number:v.number,diff:previous.number]"
+ params="[number:v,diff:previous]"
onComplete="showDiff();">Diff with previous</g:remoteLink></li>
</g:if>
<g:else>
View
20 grails.org/grails-app/views/content/_wikiInfo.gsp
@@ -21,15 +21,19 @@
</g:if>
<g:if test="${versions}">
<p>
- <strong>First Created:</strong> ${wikiPage?.dateCreated} by <strong>${versions[0].author.login}</strong>
+ <strong>First Created:</strong> ${wikiPage?.dateCreated} by <strong>${first.author.login}</strong>
</p>
<p>
- <strong>Last Updated:</strong> ${wikiPage?.lastUpdated} by <strong>${versions[-1].author.login}</strong>
+ <strong>Last Updated:</strong> ${wikiPage?.lastUpdated} by <strong>${last.author.login}</strong>
</p>
-<h3>Versions:</h3>
-<div id="versions">
- <g:render template="versionList" model="[versions:versions, wikiPage:wikiPage, update:updateElement]" />
-</div>
-</g:if>
-<g:else>No Versions</g:else>
+
+ <h3>Versions:</h3>
+ <div id="versions">
+ <cache:text id="${'versionList'+wikiPage?.id}">
+ <g:render template="versionList" model="[versions:versions,authors:authors, wikiPage:wikiPage, update:updateElement]" />
+ </cache:text>
+ </div>
+ </g:if>
+ <g:else>No Versions</g:else>
+

0 comments on commit c187e0f

Please sign in to comment.
Something went wrong with that request. Please try again.