alaska.saedelere has asked for the wisdom of the Perl Monks concerning the following question:
up to this day i have been able to struggle myself through that behemoth that is called Perl, but now i am in need of assistance.
i have inherited a piece of corporate software that makes my eyes bleed and my brain hurt. i am tasked to refactor it (at least there is SOME sanity in this) prior to implement new features. for corporate concerns i cannot post any "real" code. i try to get along with pseudo-code.
the software in question is a Perl module (used in a web-app) that receives three lists. first is a list of "group fields" (like 'username', 'book_id'), second is a list of "value fields" (like 'no_of_book_sales', 'comission_total'), third is an optional list containg filter definitions. the fields may come from up to 4 different tables. it returns the SQL to make a 'sensible' query to our database.
the parameters come from a web fronted that is designed to make it easy for our clients to create user designed queries via browser. depending on the incoming query fields the module decides from which table to select which fields in which order. there are also lots of optimizations and special cases (most of them to ensure a tight search when filtering) which are handled by a nightmarish construction of try catch, if and elseif blocks. not to mention that beast of a dispatch table that is alone capable of getting you 3 grey hairs (per day you work on it).
a very important special case is the "stats" table of which we have 3 instances. "stats_all", "stats_fast", "stats_faster". the last two are condensed (by dropping group fields and summing) versions of stats_all, each about 20%-30% of the size the bigger table. each table has a different duration. the data in stats_all only lasts 3 months, the data in stats_fast 1year and the data in stats_faster lasts (hopefully) for ever.
The current module investigate the "wanted fields" lists and selects the appropriate table to use.
At least, the connections between the source tables are relatively easy to handle. the mentioned "3 tier table" is always leading and there are only left joins.
Honestly, I have no idea how to tackle this. I read about sql-dictionaries, SQL::Abstract (which is unfriendly to nesting anonymous sub queries), and others.
someone got a cluebat for me?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inheriting Bullsh!t
by talexb (Chancellor) on Nov 30, 2009 at 19:26 UTC | |
by pemungkah (Priest) on Dec 03, 2009 at 22:12 UTC | |
|
Re: Inheriting Bullsh!t
by moritz (Cardinal) on Nov 30, 2009 at 18:42 UTC | |
|
Re: Inheriting Bullsh!t
by zentara (Cardinal) on Nov 30, 2009 at 17:32 UTC | |
| |
|
Re: Inheriting Bullsh!t
by jeffreyray (Sexton) on Dec 01, 2009 at 06:16 UTC | |
by alaska.saedelere (Initiate) on Dec 01, 2009 at 07:01 UTC | |
|
Re: Inheriting Bullsh!t
by Limbic~Region (Chancellor) on Dec 01, 2009 at 15:43 UTC |