DELETE Post WHERE Creator = findUserByEmail('andy@caerphoto.com')
OK I've attached a screen shot of the current report and my code. Here is what I need to do, and fucked if I know if I can do it.
In the screen shot you can see that everything in the description field is Red Oak except one (which is White Oak). This can change to anything.
For example we could have a batch of Cherry and then one Hard Maple in the batch.
So what I need to somehow do is get a majority of the type of wood it is and ignore the minority. Pretty complicated....
<!--- Count how many of each wood type is used... ---> <cfset WoodTypes = [] /> <cfloop query="batch_report3"> <cfset WoodName = extractWoodName(Description) /> <cfif StructKeyExists(WoodTypes,WoodName)> <cfset WoodTypes[WoodName]++ /> <cfelse> <cfset WoodTypes[WoodName] = 0 /> </cfif> </cfloop> <!--- Work out what the most common wood type is... ---> <cfset MaxCount = 0 /> <cfset MaxType = "" /> <cfloop item="CurType" collection=#WoodTypes#> <cfif WoodTypes[CurType] GT MaxCount > <cfset MaxCount = WoodTypes[CurType] /> <cfset MaxType = CurType /> </cfif> </cfloop> <cfoutput> <p>Most common wood type is "<b>#MaxType#</b>".</p> </cfoutput> <!--- Extract the name from the description. (May need changing/expanding depending on other description formats.) ---> <cffunction name="extractWoodName" returntype="string" output="false" > <cfargument name="Text" type="string" required /> <cfset var Name = rereplace(Arguments.Text,'^\d/\d x RW','') /> <cfset Name = rereplace(Arguments.Text,'(?:prime|\da?)? (?:common|boards|unselected|blocking) green') /> <cfreturn Trim(Name) /> </cffunction>
Yeah there is no doubt my code isn't nice.
I think I've found the easiest way. There is a product id table that seems to have the types in some kind of unique code. I'll take that approach.
Thanks man!