The Data Asylum

Programming, Databases and People

WTF - Scheduled Reports

Working on scheduled reporting systems, you expect to see the same concepts. What format wiil we send the report in? How will it be delivered? I opened the “scheduled report” table to see how this particular system had been implemented. I couldn’t immediately find which column i was looking for. In fact the only one that looked like it might be useful was something called deliv_method.

1
2
3
4
5
deliv_method
	206
	774
	206
	206

Ok, so we’ve got a numeric list of delivery methods. Nothing too unusual about that. I just need to find the list either in the database or codebase. But where do we store the format of the report? I worked my way through the report scheduler code until i found this.

1
2
$delivMeth = ($row['DELIV_METHOD'] >> 8);
$myFormat = ($row['DELIV_METHOD'] & 0xFF);

Are those bitwise operators? And even a literal hexadecimal number? The only place i’ve ever seen a bitwise operator is when setting the error reporting level. I’ve looked at this a few times and am still not sure i correctly understand it.

The answer eventually revealed itself.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$a = array(
	0x0104 => 'Email HTML',
	0x0204 => 'Email HTML Attachment',
	0x0284 => 'Email HTML Zipped attach',
	0x0201 => 'Email PDF',
	0x0203 => 'Email TSV delim',
	0x0283 => 'Email TSV delim zipped',
	0x0203 => 'Email CSV delim',
	0x0283 => 'Email CSV delim zipped',
	0x0304 => 'FTP HTML',
	0x0301 => 'FTP PDF',
	0x0303 => 'FTP TSV delim',
	0x0303 => 'FTP CSV delim',
	);

Pretty clever you have to admit! Unfortunately it can lead to same rather ugly code.

1
if ((($('#INPUT\\[DELIVERY_METHOD\\]').val() & 0xFF00) >> 8) != 0x03){

Comments