Monday, November 08, 2010 at 12:05 AM.

system.verbs.builtins.radio.thread.agents.everyNightUpdate

<<Changes
	<<12/21/02; 3:49:25 PM by JES
		<<Added support for serial number renewals.
	<<2/14/02; 5:49:37 PM by JES
		<<Only update radio.root, if user.radio.prefs.usernum is defined.
	<<1/6/02; 2:23:49 AM by JES
		<<Don't publish the whole month every night. This is now handled by the callback script at radio.upstream.callbacks.upstream.updateWeblogArchivePages.
	<<12/28/01; 1:01:20 PM by JES
		<<When doing the nightly build of the month's weblog pages, build the pages for the month that includes yesterday. This fixes a problem where calendars on pages in the previous wouldn't link to the last day of that month.
	<<12/16/01; 9:06:00 AM by DW
		<<Add nightly build of the month's weblog pages.
	<<12/8/01; 2:43:40 PM by DW
		<<Big corner-turn:
			<<1. Moved from radio.thread.agents.nightlyUpdates, which was coded in such a way that it couldn't be updated without crashing Radio.
			<<2. We delete radio.thread.agents.nightlyUpdates, if it exists, so we can leave its troubled past behind.
			<<3. We do the root update in a separate thread, so this script can be updated.
	<<12/8/01; 2:25:01 PM by DW
		<<Only do the updates once per day. Six times is five times too many. ;->
	<<12/2/01; 12:33:02 AM by JES
		<<After doing a root update, rebuild the menubar.
	<<12/1/01; 7:43:23 PM by DW
		<<Created. If it's time to do the nightly update, or it's been more than 24 hours since we updated, do it now.

<<user.radio.stats.dateLastUpdate = date.yesterday (user.radio.stats.dateLastUpdate) //debugging

if defined (radio.thread.agents.nightlyUpdates) { //12/8/01; 2:47:34 PM by DW
	delete (@radio.thread.agents.nightlyUpdates)};

if not tcp.isOffline () {
	local (now = clock.now ());
	local (flupdate = false);
	local (day, month, year, hour, minute, second);
	date.get (now, @day, @month, @year, @hour, @minute, @second);
	if (hour == 0) and (minute == user.radio.settings.minuteToDoNightlyTasks) {
		local (lastday, lastmonth, lastyear, lasthour, lastminute, lastsecond);
		date.get (user.radio.stats.dateLastUpdate, @lastday, @lastmonth, @lastyear, @lasthour, @lastminute, @lastsecond);
		if lastday != day { //only do the updates once per day
			flupdate = true}}
	else {
		if date.yesterday (now) > user.radio.stats.dateLastUpdate { //it's been more than 24 hours
			flupdate = true}};
	bundle { //expiration check
		if flupdate {
			if defined (user.radio.settings.whenSNExpires) {
				local (whenExpires = date (user.radio.settings.whenSNExpires));
				if whenExpires < now {
					flupdate = false}}}};
	if flupdate {
		user.radio.stats.dateLastUpdate = now;
		if user.radio.prefs.flUpdateDatabaseNightly { //Update Radio.root
			if defined (user.radio.prefs.usernum) { //2/14/02 JES: Only update radio.root if we have a usernum.
				local (adrscript = @system.temp.rootUpdate);
				adrscript^ = radio.utilities.rootUpdate;
				thread.callScript (adrscript, {@root})}};
		<<if user.radio.prefs.flBuildWeblogMonthNightly
			<<radio.weblog.publishMonth (date.yesterday (now))
		if user.radio.prefs.flReloadHotlistNightly {
			try {radio.hotlist.reload ()}};
		if user.radio.prefs.glossary.flReadNightly {
			try {radio.utilities.readGlobalGlossary ()}}}}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.