Comparing sensitive data, confidential files or internal emails?

Most legal and privacy policies prohibit uploading sensitive data online. Diffchecker Desktop ensures your confidential information never leaves your computer. Work offline and compare documents securely.

final

Created Diff never expires
56 removals
54 lines
54 additions
52 lines

















[I've experimented further; but I couldn't improve it significantly. Below is the total change between 5v-lots and final version.]




// temperature generally between 0.2-0.4 for these. Stuff in [] is not present in the prompts ofc.
// List of "Edit" commands I ran (transforming left (second panel) to the right):
// - Improve the formatting, concerning the whitespace and SQL case consistency (make SQL names uppercase).
// - Rename frmSQLGridFrame1 to something shorter and appropiate.
// - Rename fnGetSqlConditions to something shorter and appropiate to its description (comment)
// [I added it to try to guide GPT this way, because it kinda sucked at renaming stuff].
// - Rename fnGetSqlTimeConditions [intermediate name] - 'condition' is too long and generic. And not time - timespan.
// - Rename ASqlColumnName to something terser.
// - Replace %s with ''%s'' to get rid of QuotedStr. [somehow it just couldn't do it with subtler prompts]
// - Remove sorting from the query.
// - Improve formatting: spacing, line breaks etc.
// - Formatting: Remove unnecessary table aliases (prefix)
// [[ Bonus: at the end there's a result of asking GPT to comment the code: https://www.diffchecker.com/1J37dhgo
// I didn't specify the language, so... (English ones are just Deepl translations; turns out these aren't even completely nonsensical. ]]


// Returns cond checking whether a timestamp is between two other timestamps
// Returns cond checking whether a timestamp is between two other timestamps
function fnGetSqlConditions(const ASqlColumnName: String;
function fnGetSqlTimeSpan(const AColumnName: String;
const ADatePicker: TDatePickerFrame;
const ADatePicker: TDatePickerFrame;
const ATimePickerFrom, ATimePickerTo: TTimePickerFrame): String;
const ATimePickerFrom, ATimePickerTo: TTimePickerFrame): String;
begin
begin
if (ADatePicker.DateFrom = 0) and (ADatePicker.DateTo = 0) then
if (ADatePicker.DateFrom = 0) and (ADatePicker.DateTo = 0) then
Exit('');
Exit('');

Result := Format(' and %s between ''%s'' and ''%s'' ',
Result := Format(' and %s between %s and %s', [
[AColumnName,
ASqlColumnName,
fnDateToSqlStr(ADatePicker.DateFrom
QuotedStr(fnDateToSqlStr(ADatePicker.DateFrom + IfThen(ATimePickerFrom.fnIsEmpty(), 0, ATimePickerFrom.Value))),
+ IfThen(ATimePickerFrom.fnIsEmpty(), 0, ATimePickerFrom.Value)),
QuotedStr(fnDateToSqlStr(IfThen(ADatePicker.DateTo = 0, High(TDateTime), ADatePicker.DateTo) + IfThen(ATimePickerTo.fnIsEmpty(), 0.999, ATimePickerTo.Value)))
fnDateToSqlStr(IfThen(ADatePicker.DateTo = 0, High(TDateTime), ADatePicker.DateTo)
]);
+ IfThen(ATimePickerTo.fnIsEmpty(), 0.999, ATimePickerTo.Value))]);
end;
end;




procedure TfmWebLogForm.prOpenSQL;
procedure TfmWebLogForm.prOpenSQL;
const
const
C_SQL = 'select hdl_d11, hdl_d02_d11, hdl_007_d11, hdl_d11_d11, event_d11, '
C_SQL = 'select HDL_D11, HDL_D02_D11, HDL_007_D11, HDL_D11_D11, EVENT_D11, '
+ ' time_d11, '
+ 'TIME_D11, REMOTE_IP_D11, USER_D11, SESSION_ID_D11, URL_D11, CONTENT_TYPE_D11, CONTENT_D11'
+ ' remote_ip_d11, user_d11, session_id_d11, url_d11, content_type_d11, content_d11'
+ ' from TWEB_SRV_LOG_D11 where '
+ ' from tweb_srv_log_d11 d11 where'
+ 'HDL_D11_D11 is null ';
+ ' d11.hdl_d11_d11 is null';
begin
begin
frmSQLGrid.SQLText := C_SQL;
frmSQLGridFrame1.SQLText := C_SQL;
if (HdlD02 <> 0) then
if (HdlD02 <> 0) then
frmSQLGrid.SQLText := frmSQLGrid.SQLText + Format(' and HDL_D02_D11 = %d ', [HdlD02]);
frmSQLGridFrame1.SQLText := frmSQLGridFrame1.SQLText + Format(' and HDL_D02_D11 = %d', [HdlD02]);
frmSQLGrid.SQLText := frmSQLGrid.SQLText
frmSQLGridFrame1.SQLText := frmSQLGridFrame1.SQLText
+ fnGetSqlTimeSpan('DATA_INS_D11', dpCreated, edtTimeCreatedFrom, edtTimeCreatedTo)
+ fnGetSqlConditions('DATA_INS_D11', dpCreated, edtTimeCreatedFrom, edtTimeCreatedTo)
+ fnGetSqlTimeSpan('TIME_D11', dpExecuted, edtTimeExecutedFrom, edtTimeExecutedTo);
+ fnGetSqlConditions('TIME_D11', dpExecuted, edtTimeExecutedFrom, edtTimeExecutedTo)
frmSQLGrid.prOpenQuery;
+ ' order by DATA_INS_D11 desc';
frmSQLGrid.OnRowRefresh := prRowInfo;
frmSQLGridFrame1.prOpenQuery;
frmSQLGrid.VisibleColumnsList.Values['DATA_INS_D11'] := 'Created';
frmSQLGridFrame1.OnRowRefresh := prRowInfo;
frmSQLGridFrame1.VisibleColumnsList.Values['DATA_INS_D11'] := 'Created';
end;
end;