Tuesday, March 29, 2011 at 1:07 AM.

river2Suite.background.everyMinute

on everyMinute () {
	<<Changes
		<<3/27/11; 6:48:43 PM by DW
			<<Maintenence flag to create user accounts for all River2 users in members.root.
		<<2/4/11; 10:04:45 AM by DW
			<<Only init "user" tables that are actually tables. This avoids problems if users accidentally leave an "item #1" in the users table.
		<<11/17/10; 1:12:31 PM by DW
			<<Rebuild the static pages if necessary.
		<<11/13/10; 10:59:34 AM by DW
			<<Init each user once a minute.
		<<11/2/10; 7:02:52 PM by DW
			<<If minutesBetweenScans is 30 or less, do the scan if the current minute is evenly divided by the count. So if you've set it to 20 minutes between scans, you'll get a scan at 20 minutes into the hour, 40 minutes, and at the top of the hour. 
			<<If it's greater than 30, then do the scan if it's been greater than minutesBetweenScans since the last scan. 
			<<If this ever becomes a dominant product, we'll have to change the algorithm so they aren't all scanning at the same time. 
		<<10/27/10; 10:30:54 PM by DW
			<<Comment out the adrdata^.flags.moveEveryMinute maintenence code.
		<<10/6/10; 4:50:37 AM by DW
			<<Moves back into the background table, now that we're using scheduler2 as the main scheduler, no reason to keep this outside any longer.
		<<6/22/10; 11:07:04 AM by DW
			<<We broke the process for releasing Rebooting the News. If River2 read the feed while the post was public but didn't have the MP3 linked in, then the user didn't get yesterday's show. Simple fix, remove the history element for the podcast if it's defined, so the item will be read again and this time the podcast should be downloaded.
		<<5/4/10; 12:17:43 PM by DW
			<<A maintenence flag to undo the initialization of adrdata^.prefs.static.flJavaScriptInclude.
		<<3/19/10; 8:21:26 AM by DW
			<<A maintenence flag that corrects a mistake in updating the Prefs outline.
				<<http://river2.org/2010/03/19/how-to-update-the-prefs-outline-in-river2/
		<<12/25/09; 11:11:11 AM by DW
			<<Launch the cloudPipeClient thread if it's enabled.
		<<12/21/09; 4:14:45 AM by DW
			<<New maintenence flag, clean up the announcements structure.
		<<9/16/09; 7:01:24 PM by DW
			<<This script moves from the background table to the top level of the river2 suite. It's now called by scheduler2, which is much more robust than the first scheduler.
		<<9/9/09; 7:34:33 AM by DW
			<<Add a flag that controls whether we check the enclosure download queues. This helps with debugging. (I turn it off when I don't want them to download right now, like turning off the Bay Bridge over Labor Day weekend.)
		<<9/8/09; 1:45:09 PM by DW
			<<Check all enclosure queues.
		<<9/2/09; 10:25:50 AM by DW
			<<maxMegsFix maintenence.
		<<8/24/09; 9:02:28 PM by DW
			<<Check if any podcasts are ready to download.
		<<8/16/09; 6:58:18 PM by DW
			<<Add maintenence checks bundle.
		<<6/16/09; 2:04:06 PM by DW
			<<Created. 
	local (adrdata = river2suite.init (), now = clock.now ());
	adrdata^.stats.ctEveryMinutes++;
	bundle { //init each user, 11/13/10 by DW
		local (adruser);
		for adruser in @adrdata^.users {
			if typeof (adruser^) == tabletype { //2/4/11 by DW
				river2Suite.initUser (adruser)}}};
	bundle { //do the scan if it's time to do it
		if adrdata^.prefs.enabled {
			local (flscan = false, minutesBetween = adrdata^.prefs.minutesBetweenScans);
			if minutesBetween <= 30 {
				if (date.minute () % minutesBetween) == 0 {
					flscan = true}}
			else {
				if adrdata^.stats.whenLastScanStart == date (0) {
					flscan = true}
				else {
					local (ctminutes = number (clock.now () - adrdata^.stats.whenLastScanStart) / 60);
					if ctminutes >= minutesBetween {
						flscan = true}}};
			if flscan {
				river2Suite.doScanNow ()}}};
	bundle { //launch the cloudPipeClient thread if it's enabled, 12/25/09 by DW
		if adrdata^.prefs.cloudPipeClient.enabled {
			local (fllaunch = true);
			if defined (system.temp.river2.idCloudPipeClient) {
				if thread.exists (system.temp.river2.idCloudPipeClient) {
					fllaunch = false}};
			if fllaunch {
				system.temp.river2.idCloudPipeClient = thread.callscript (@river2Suite.cloudPipe.client, {})}}
		else {
			if defined (system.temp.river2.idCloudPipeClient) {
				delete (@system.temp.river2.idCloudPipeClient)}}};
	bundle { //maintenence checks
		if not defined (adrdata^.flags.maxMegsFix) { //9/2/09 by DW
			if defined (adrdata^.prefs.maxFolderMegs) {
				delete (@adrdata^.prefs.maxFolderMegs)};
			adrdata^.flags.maxMegsFix = now};
		if not defined (adrdata^.flags.readingListStartup) {
			local (adrfeed);
			for adrfeed in @adrdata^.feeds { //all existing feeds are not from reading lists
				adrfeed^.prefs.flNonListSubscribe = true};
			adrdata^.flags.readingListStartup = now};
		<<if not defined (adrdata^.flags.moveEveryMinute) //commented 10/27/10 by DW
			<<try {delete (@river2Suite.background.everyMinute)}
			<<adrdata^.flags.moveEveryMinute = now
		if not defined (adrdata^.flags.cleanUpAnnouncements) { //12/21/09 by DW
			try {delete (@river2Suite.data.announcement)};
			try {delete (@river2Suite.data.announcementArchive)};
			adrdata^.flags.cleanUpAnnouncements = now};
		if not defined (adrdata^.flags.correctRiver2Prefs) { //3/19/10 by DW
			local (addresslist = string.parseaddress (this), f = addresslist [1], adrprefs = @[f].["#installer"].prefs);
			if defined (adrprefs^) {
				delete (adrprefs)};
			adrprefs^ = "river2Suite.data.prefsOutline";
			adrdata^.flags.correctRiver2Prefs = now};
		if not defined (adrdata^.flags.deleteStaticJsPref) { //5/4/10 by DW
			try {delete (@adrdata^.prefs.static.flJavaScriptInclude)};
			adrdata^.flags.deleteStaticJsPref = now};
		if not defined (adrdata^.flags.fixMissingRebootNewsPodcast) { //6/22/10 by DW
			try {delete (@adrdata^.feeds.["http://rebootnews.com/feed/"].history.["http://rebootnews.com/?p=443"])};
			adrdata^.flags.fixMissingRebootNewsPodcast = now};
		if not defined (adrdata^.flags.deleteOldEveryMinuteScript) { //10/6/10 by DW
			try {delete (@river2Suite.everyMinute)};
			adrdata^.flags.deleteOldEveryMinuteScript = now};
		if not defined (adrdata^.flags.initMembersRoot) { //3/27/11 by DW
			try {river2Suite.utilities.initMembersRoot ()};
			adrdata^.flags.initMembersRoot = now}};
	bundle { //rebuild the static pages if necessary, 11/17/10; 1:07:30 PM by DW
		if system.temp.river2.flStaticBuild {
			river2Suite.static.runBuildThread ()}}};
bundle { //test code
	everyMinute ()}



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.