mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
CE-1836: added potential to log output
This commit is contained in:
@ -23,6 +23,8 @@ package com.kingsrook.qqq.backend.core.processes.implementations.tablesync;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -35,6 +37,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
|
||||
import com.kingsrook.qqq.backend.core.actions.values.QPossibleValueTranslator;
|
||||
import com.kingsrook.qqq.backend.core.actions.values.QValueFormatter;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
||||
@ -53,6 +56,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryJoin;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.session.QSession;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.AbstractTransformStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.StreamedETLWithFrontendProcess;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.general.StandardProcessSummaryLineProducer;
|
||||
@ -113,6 +117,7 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
||||
|
||||
protected static final String SYNC_TABLE_PERFORM_INSERTS_KEY = "syncTablePerformInsertsKey";
|
||||
protected static final String SYNC_TABLE_PERFORM_UPDATES_KEY = "syncTablePerformUpdatesKey";
|
||||
protected static final String LOG_TRANSFORM_RESULTS = "logTransformResults";
|
||||
|
||||
|
||||
|
||||
@ -237,6 +242,7 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
||||
{
|
||||
if(CollectionUtils.nullSafeIsEmpty(runBackendStepInput.getRecords()))
|
||||
{
|
||||
LOG.info("No input records were found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -406,6 +412,53 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
||||
possibleValueTranslator.translatePossibleValuesInRecords(QContext.getQInstance().getTable(destinationTableName), runBackendStepOutput.getRecords());
|
||||
}
|
||||
}
|
||||
|
||||
if(runBackendStepInput.getValueString(SYNC_TABLE_PERFORM_INSERTS_KEY) != null)
|
||||
{
|
||||
logResults(runBackendStepInput, config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Log results of transformation
|
||||
**
|
||||
*******************************************************************************/
|
||||
protected void logResults(RunBackendStepInput runBackendStepInput, SyncProcessConfig syncProcessConfig)
|
||||
{
|
||||
String timezone = QContext.getQSession().getValue(QSession.VALUE_KEY_USER_TIMEZONE);
|
||||
if(timezone == null)
|
||||
{
|
||||
timezone = QContext.getQInstance().getDefaultTimeZoneId();
|
||||
}
|
||||
ZonedDateTime dateTime = runBackendStepInput.getBasepullLastRunTime().atZone(ZoneId.of(timezone));
|
||||
|
||||
if(syncProcessConfig.performInserts)
|
||||
{
|
||||
if(okToInsert.getCount() == 0)
|
||||
{
|
||||
LOG.info("No Records were found to insert since " + QValueFormatter.formatDateTimeWithZone(dateTime) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
String pluralized = okToInsert.getCount() > 1 ? " Records were " : " Record was ";
|
||||
LOG.info(okToInsert.getCount() + pluralized + " found to insert since " + QValueFormatter.formatDateTimeWithZone(dateTime) + ".", logPair("primaryKeys", okToInsert.getPrimaryKeys()));
|
||||
}
|
||||
}
|
||||
|
||||
if(syncProcessConfig.performUpdates)
|
||||
{
|
||||
if(okToUpdate.getCount() == 0)
|
||||
{
|
||||
LOG.info("No Records were found to update since " + QValueFormatter.formatDateTimeWithZone(dateTime) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
String pluralized = okToUpdate.getCount() > 1 ? " Records were " : " Record was ";
|
||||
LOG.info(okToUpdate.getCount() + pluralized + " found to update since " + QValueFormatter.formatDateTimeWithZone(dateTime) + ".", logPair("primaryKeys", okToInsert.getPrimaryKeys()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user