Skip to content

Commit

Permalink
Inject table name for logs (fixes #96)
Browse files Browse the repository at this point in the history
  • Loading branch information
geirsagberg committed Jul 9, 2024
1 parent d5a72e1 commit 9efe7fc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ LogLogic logLogic(
DataSource dataSource,
Caching caching,
DbSchedulerCustomizer customizer,
DbSchedulerUiProperties properties) {
DbSchedulerUiProperties properties,
@Value("${db-scheduler-log.table-name:scheduled_execution_logs}") String logTableName) {
return new LogLogic(
dataSource,
customizer.serializer().orElse(Serializer.DEFAULT_JAVA_SERIALIZER),
caching,
properties.isTaskData());
properties.isTaskData(),
logTableName);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class TaskModel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ public class LogLogic {
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
private final Caching caching;
private final LogModelRowMapper logModelRowMapper;

public LogLogic(DataSource dataSource, Serializer serializer, Caching caching, boolean showData) {
private final String logTableName;

public LogLogic(
DataSource dataSource,
Serializer serializer,
Caching caching,
boolean showData,
String logTableName) {
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
// currently we have no paging in the UI
this.namedParameterJdbcTemplate.getJdbcTemplate().setMaxRows(DEFAULT_LIMIT);
this.caching = caching;
this.logTableName = logTableName;
this.logModelRowMapper =
new LogModelRowMapper(
showData, serializer == null ? Serializer.DEFAULT_JAVA_SERIALIZER : serializer);
Expand Down Expand Up @@ -79,7 +86,7 @@ public LogPollResponse pollLogs(TaskDetailsRequestParams requestParams) {
}

public List<LogModel> getLogsDirectlyFromDB(TaskDetailsRequestParams requestParams) {
QueryBuilder queryBuilder = QueryBuilder.selectFromTable("scheduled_execution_logs");
QueryBuilder queryBuilder = QueryBuilder.selectFromTable(logTableName);
if (requestParams.getStartTime() != null) {
queryBuilder.andCondition(
new TimeCondition(
Expand Down

0 comments on commit 9efe7fc

Please sign in to comment.