Page 1 of 1

Bug with 3.1 and Prune

Posted: Wed Jan 04, 2006 10:05 am
by Jenlor
When I press Prune with the new 3.1 I get the following error:

Interface\Addons\CensusPlus\CensusPlus.lu
a:2588: attempt to perform arithmetic on gl
obal `timesPruneCount' (a nil value)

Posted: Wed Jan 04, 2006 11:39 am
by Rollie
Did you click the Prune button? Or use a /census prune command?

Posted: Wed Jan 04, 2006 11:47 am
by semidar
was just about to post the same problem. I used the button.

I tried /census prune and received a command line help listing, so I tried /censusplus prune 30 and got the same/original error msg.

Posted: Wed Jan 04, 2006 12:33 pm
by Rollie
Hrm.. okay, thanks, will look into it tonight.

Posted: Wed Jan 04, 2006 12:44 pm
by Rollie
Ah, okay, I just took a look at the code and found the culprit.

I cannot test this until I get home tonight, but would one of you (or someone else having this issue) that is comfortable editing the files make this modification and post here the results?

In the file \Interface\AddOns\CensusPlus\CensusPlus.lua, on line 2566, remove the function CensusPlus_PruneTimes(), as shown here:

Code: Select all

function CensusPlus_PruneTimes()
	local pruneDays = 60*60*24*21; --  num seconds 

	for realmName, realmDatabase in pairs(CensusPlus_Database["TimesPlus"]) do
		if (realmName ~= nil ) then
			for factionName, factionDatabase in pairs(realmDatabase) do
				if ( factionName ~= nil) then
					for moment, count in pairs( factionDatabase ) do
						--  Moment is in format of YYYY-MM-DD&HH:MM
						local test = string.sub( moment, 1, 2 );
						local tYear, tMonth, tDay;
						tYear = string.sub( moment,  1, 4 );
						tMonth = string.sub( moment, 6, 7 );
						tDay   = string.sub( moment, 9, 10 );
						local momentTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} );

						if( time() - momentTime > pruneDays ) then
							--  cull entry
							CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")][moment] = nil;
							moment = nil;
							timesPruneCount = timesPruneCount + 1;
						end
					end
				end
			end
		end
	end
end
and replace with:

Code: Select all

function CensusPlus_PruneTimes()
	local pruneDays = 60*60*24*21; --  num seconds 

    local accumTimesData = {};
	for realmName, realmDatabase in pairs(CensusPlus_Database["TimesPlus"]) do
		if (realmName ~= nil ) then
			for factionName, factionDatabase in pairs(realmDatabase) do
				if ( factionName ~= nil) then
					for moment, count in pairs( factionDatabase ) do
						--  Moment is in format of YYYY-MM-DD&HH:MM
						local test = string.sub( moment, 1, 2 );
						local tYear, tMonth, tDay;
						tYear = string.sub( moment,  1, 4 );
						tMonth = string.sub( moment, 6, 7 );
						tDay   = string.sub( moment, 9, 10 );
						local momentTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} );

						if( time() - momentTime > pruneDays ) then
							--  cull entry
	                        local pruneData = {};
	                        pruneData.realm = realm;
	                        pruneData.faction = faction;
-- EDIT: change the above 2 lines to :

Code: Select all

	                        pruneData.realm = realmName;
	                        pruneData.faction = factionName;
and the rest:

Code: Select all

	                        pruneData.entry = moment;
	                        table.insert(accumTimesData, pruneData);
						end
					end
				end
			end
		end
	end
	
	local num = table.getn(accumTimesData);
	while( num > 0 )do
		--
		-- Remove the top job from the queue and send it
		--
		local pruneData = accumTimesData[num];

        CensusPlus_Database["TimesPlus"][pruneData.realm][pruneData.faction][pruneData.entry] = {};
        CensusPlus_Database["TimesPlus"][pruneData.realm][pruneData.faction][pruneData.entry] = nil;

		table.remove(accumTimesData);
		num = table.getn(accumTimesData);
	end
end

Posted: Wed Jan 04, 2006 1:14 pm
by Khryss
Tried to make above modifications, now I get

Error: Interface\AddOns\CensusPlus\CensusPlus.lua:2606: attempt to index field `?' (a nil value)

Posted: Wed Jan 04, 2006 3:20 pm
by Rollie
bah, okay, I'll be home shortly, can check it out in a bit

Posted: Thu Jan 05, 2006 1:05 am
by Rollie
Fix posted:

http://www.warcraftrealms.com/censusmod ... -3.1.2.zip

alternately, in the above code segment, you can change the

Code: Select all

                          pruneData.realm = realm;
                           pruneData.faction = faction;
to

Code: Select all

	                        pruneData.realm = realmName;
	                        pruneData.faction = factionName;