Permalink
Browse files

updated screencasts link, improved memory efficiency of scheduled jobs

  • Loading branch information...
1 parent c659a31 commit bac11efb36a88f94e86f0e8113af60f97f7e3e2c @graemerocher graemerocher committed Nov 10, 2009
@@ -7,6 +7,7 @@ import org.codehaus.groovy.grails.web.context.ServletContextHolder
import javax.servlet.ServletContext
import org.grails.content.Version
import org.grails.plugin.Plugin
+import org.codehaus.groovy.grails.plugins.*
class MailerJob {
def startDelay = 60000
@@ -18,52 +19,60 @@ class MailerJob {
def cacheService
def execute() {
- Content content = contentToMessage?.popOffStack()
- if (content) {
- ServletContext servletContext = ServletContextHolder.servletContext
- def context = new BaseInitialRenderContext();
- context.set(GrailsWikiEngine.CONTEXT_PATH, servletContext.contextPath)
- context.set(GrailsWikiEngine.CACHE, cacheService)
- def engine = new GrailsWikiEngine(context)
+ try {
+ Content content = contentToMessage?.popOffStack()
+ if (content) {
+ ServletContext servletContext = ServletContextHolder.servletContext
+ def context = new BaseInitialRenderContext();
+ context.set(GrailsWikiEngine.CONTEXT_PATH, servletContext.contextPath)
+ context.set(GrailsWikiEngine.CACHE, cacheService)
+ def engine = new GrailsWikiEngine(context)
- context.setRenderEngine engine
- def users = UserInfo.findAllByEmailSubscribed(true).user
- while (content) {
- def plugin = pluginService.resolvePossiblePlugin(content)
- def text = new StringBuffer()
- def titleUrlEscaped = content.title.encodeAsURL()
- def url = "http://grails.org/${titleUrlEscaped}"
- def myTitle = content.title
- // make some alterations to the email if this wiki is a part of a plugin
- if (plugin instanceof Plugin) {
- url = "http://grails.org/plugin/${plugin.name}"
- def wikiType = content.title.split('-')[0]
- myTitle = "${plugin.title} (${wikiType[0].toUpperCase() + wikiType[1..-1]} tab)"
- }
+ context.setRenderEngine engine
+ def emails = UserInfo.executeQuery("select ui.user.email from UserInfo as ui where ui.emailSubscribed = ?", [false] )
+ while (content) {
+ def plugin = pluginService.resolvePossiblePlugin(content)
+ def text = new StringBuffer()
+ def titleUrlEscaped = content.title.encodeAsURL()
+ def url = "http://grails.org/${titleUrlEscaped}"
+ def myTitle = content.title
+ // make some alterations to the email if this wiki is a part of a plugin
+ if (plugin instanceof Plugin) {
+ url = "http://grails.org/plugin/${plugin.name}"
+ def wikiType = content.title.split('-')[0]
+ myTitle = "${plugin.title} (${wikiType[0].toUpperCase() + wikiType[1..-1]} tab)"
+ }
- def pageVersions = Version.findAllByCurrent(content)
- pageVersions = pageVersions.sort { it.number }
+ def pageVersions = Version.findAllByCurrent(c, [sort:'number',order:'desc', max:1, cache:true])
- def version = pageVersions[-1] //last version
- text << '<div style="color:black;"><br><br>'
- text << "Page <a href=\"${url}\">${myTitle}<a/> <br><br>"
- text << "</div>"
- text << '<div style="color:black;"><br><br>'
- text << "Edited by <b>${version.author?.login}</b>. <a href=\"http://grails.org/previous/${titleUrlEscaped}/${version.number}\">View change</a> <br><br>"
- text << "</div>"
- text << engine.render(content.body, context)
+ if(pageVersions) {
+ def version = pageVersions[-1] //last version
+ text << "<div>To unsubscribe from receiving these emails go to <a href=\"http://grails.org/profile\">http://grails.org/profile</a>, login and uncheck the 'Receive E-mail Updates for Content Changes?' box. </div><br><br>"
+ text << '<div style="color:black;"><br><br>'
+ text << "Page <a href=\"${url}\">${myTitle}<a/> <br><br>"
+ text << "</div>"
+ text << '<div style="color:black;"><br><br>'
+ text << "Edited by <b>${version.author?.login}</b>. <a href=\"http://grails.org/previous/${titleUrlEscaped}/${version.number}\">View change</a> <br><br>"
+ text << "</div>"
+ text << engine.render(content.body, context)
- for (user in users) {
- mailService?.sendMail {
- title "Grails > ${myTitle}"
- from "wiki@grails.org"
- replyTo "wiki@grails.org"
- to user.email
- html text.toString()
- }
- }
- content = contentToMessage?.popOffStack()
- }
- }
+ for (email in emails) {
+ mailService?.sendMail {
+ title "Grails > ${myTitle}"
+ from "wiki@grails.org"
+ replyTo "wiki@grails.org"
+ to email
+ html text.toString()
+ }
+ }
+ }
+ content = contentToMessage?.popOffStack()
+ Content.withSession { session -> session.clear() }
+ }
+ }
+ }
+ finally {
+ DomainClassGrailsPlugin.PROPERTY_INSTANCE_MAP.clear()
+ }
}
}
@@ -1,3 +1,4 @@
+import org.codehaus.groovy.grails.plugins.*
class TagCleanupJob {
def tagService
@@ -6,7 +7,12 @@ class TagCleanupJob {
def execute() {
log.info "Starting tag cleanup..."
- tagService.removeEmptyTags()
+ try {
+ tagService.removeEmptyTags()
+ }
+ finally {
+ DomainClassGrailsPlugin.PROPERTY_INSTANCE_MAP.clear()
+ }
}
}
@@ -140,7 +140,7 @@
<h2>Recent Screencasts</h2>
<div class="castBox">
<div class="castScreen">
- <a href="http://www.cloudfoundry.com/video.html">
+ <a href="https://www.cloudfoundry.com/screencasts.html#grails">
<img src="/images/new/play_icon.png"/>
</a>
<%--<g:link controller="screencast" action="show" id="${latestScreencastId}">

0 comments on commit bac11ef

Please sign in to comment.