view optimization
This commit is contained in:
@ -23,7 +23,7 @@ apply plugin: 'maven-publish'
|
|||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
|
|
||||||
group = 'de.jottyfan'
|
group = 'de.jottyfan'
|
||||||
version = '20240103'
|
version = '20240103b'
|
||||||
def artifactId = 'timetrackjooq'
|
def artifactId = 'timetrackjooq'
|
||||||
def versionNumber = version
|
def versionNumber = version
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import de.jottyfan.timetrack.db.done.Done;
|
|||||||
import de.jottyfan.timetrack.db.done.tables.records.VDaylimitRecord;
|
import de.jottyfan.timetrack.db.done.tables.records.VDaylimitRecord;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.jooq.Field;
|
import org.jooq.Field;
|
||||||
@ -25,6 +26,7 @@ import org.jooq.TableOptions;
|
|||||||
import org.jooq.impl.DSL;
|
import org.jooq.impl.DSL;
|
||||||
import org.jooq.impl.SQLDataType;
|
import org.jooq.impl.SQLDataType;
|
||||||
import org.jooq.impl.TableImpl;
|
import org.jooq.impl.TableImpl;
|
||||||
|
import org.jooq.types.YearToSecond;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,22 +53,22 @@ public class VDaylimit extends TableImpl<VDaylimitRecord> {
|
|||||||
/**
|
/**
|
||||||
* The column <code>done.v_daylimit.daytime_from</code>.
|
* The column <code>done.v_daylimit.daytime_from</code>.
|
||||||
*/
|
*/
|
||||||
public final TableField<VDaylimitRecord, String> DAYTIME_FROM = createField(DSL.name("daytime_from"), SQLDataType.CLOB, this, "");
|
public final TableField<VDaylimitRecord, LocalTime> DAYTIME_FROM = createField(DSL.name("daytime_from"), SQLDataType.LOCALTIME(6), this, "");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The column <code>done.v_daylimit.daytime_until</code>.
|
* The column <code>done.v_daylimit.daytime_until</code>.
|
||||||
*/
|
*/
|
||||||
public final TableField<VDaylimitRecord, String> DAYTIME_UNTIL = createField(DSL.name("daytime_until"), SQLDataType.CLOB, this, "");
|
public final TableField<VDaylimitRecord, LocalTime> DAYTIME_UNTIL = createField(DSL.name("daytime_until"), SQLDataType.LOCALTIME(6), this, "");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The column <code>done.v_daylimit.dayworktime</code>.
|
* The column <code>done.v_daylimit.dayworktime</code>.
|
||||||
*/
|
*/
|
||||||
public final TableField<VDaylimitRecord, String> DAYWORKTIME = createField(DSL.name("dayworktime"), SQLDataType.CLOB, this, "");
|
public final TableField<VDaylimitRecord, LocalTime> DAYWORKTIME = createField(DSL.name("dayworktime"), SQLDataType.LOCALTIME(6), this, "");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The column <code>done.v_daylimit.breaks</code>.
|
* The column <code>done.v_daylimit.breaks</code>.
|
||||||
*/
|
*/
|
||||||
public final TableField<VDaylimitRecord, String> BREAKS = createField(DSL.name("breaks"), SQLDataType.CLOB, this, "");
|
public final TableField<VDaylimitRecord, YearToSecond> BREAKS = createField(DSL.name("breaks"), SQLDataType.INTERVAL, this, "");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The column <code>done.v_daylimit.day</code>.
|
* The column <code>done.v_daylimit.day</code>.
|
||||||
@ -160,14 +162,14 @@ public class VDaylimit extends TableImpl<VDaylimitRecord> {
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Row6<String, String, String, String, LocalDate, Integer> fieldsRow() {
|
public Row6<LocalTime, LocalTime, LocalTime, YearToSecond, LocalDate, Integer> fieldsRow() {
|
||||||
return (Row6) super.fieldsRow();
|
return (Row6) super.fieldsRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience mapping calling {@link SelectField#convertFrom(Function)}.
|
* Convenience mapping calling {@link SelectField#convertFrom(Function)}.
|
||||||
*/
|
*/
|
||||||
public <U> SelectField<U> mapping(Function6<? super String, ? super String, ? super String, ? super String, ? super LocalDate, ? super Integer, ? extends U> from) {
|
public <U> SelectField<U> mapping(Function6<? super LocalTime, ? super LocalTime, ? super LocalTime, ? super YearToSecond, ? super LocalDate, ? super Integer, ? extends U> from) {
|
||||||
return convertFrom(Records.mapping(from));
|
return convertFrom(Records.mapping(from));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +177,7 @@ public class VDaylimit extends TableImpl<VDaylimitRecord> {
|
|||||||
* Convenience mapping calling {@link SelectField#convertFrom(Class,
|
* Convenience mapping calling {@link SelectField#convertFrom(Class,
|
||||||
* Function)}.
|
* Function)}.
|
||||||
*/
|
*/
|
||||||
public <U> SelectField<U> mapping(Class<U> toType, Function6<? super String, ? super String, ? super String, ? super String, ? super LocalDate, ? super Integer, ? extends U> from) {
|
public <U> SelectField<U> mapping(Class<U> toType, Function6<? super LocalTime, ? super LocalTime, ? super LocalTime, ? super YearToSecond, ? super LocalDate, ? super Integer, ? extends U> from) {
|
||||||
return convertFrom(toType, Records.mapping(from));
|
return convertFrom(toType, Records.mapping(from));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,75 +7,77 @@ package de.jottyfan.timetrack.db.done.tables.records;
|
|||||||
import de.jottyfan.timetrack.db.done.tables.VDaylimit;
|
import de.jottyfan.timetrack.db.done.tables.VDaylimit;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
import org.jooq.Field;
|
import org.jooq.Field;
|
||||||
import org.jooq.Record6;
|
import org.jooq.Record6;
|
||||||
import org.jooq.Row6;
|
import org.jooq.Row6;
|
||||||
import org.jooq.impl.TableRecordImpl;
|
import org.jooq.impl.TableRecordImpl;
|
||||||
|
import org.jooq.types.YearToSecond;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is generated by jOOQ.
|
* This class is generated by jOOQ.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||||
public class VDaylimitRecord extends TableRecordImpl<VDaylimitRecord> implements Record6<String, String, String, String, LocalDate, Integer> {
|
public class VDaylimitRecord extends TableRecordImpl<VDaylimitRecord> implements Record6<LocalTime, LocalTime, LocalTime, YearToSecond, LocalDate, Integer> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>done.v_daylimit.daytime_from</code>.
|
* Setter for <code>done.v_daylimit.daytime_from</code>.
|
||||||
*/
|
*/
|
||||||
public void setDaytimeFrom(String value) {
|
public void setDaytimeFrom(LocalTime value) {
|
||||||
set(0, value);
|
set(0, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>done.v_daylimit.daytime_from</code>.
|
* Getter for <code>done.v_daylimit.daytime_from</code>.
|
||||||
*/
|
*/
|
||||||
public String getDaytimeFrom() {
|
public LocalTime getDaytimeFrom() {
|
||||||
return (String) get(0);
|
return (LocalTime) get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>done.v_daylimit.daytime_until</code>.
|
* Setter for <code>done.v_daylimit.daytime_until</code>.
|
||||||
*/
|
*/
|
||||||
public void setDaytimeUntil(String value) {
|
public void setDaytimeUntil(LocalTime value) {
|
||||||
set(1, value);
|
set(1, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>done.v_daylimit.daytime_until</code>.
|
* Getter for <code>done.v_daylimit.daytime_until</code>.
|
||||||
*/
|
*/
|
||||||
public String getDaytimeUntil() {
|
public LocalTime getDaytimeUntil() {
|
||||||
return (String) get(1);
|
return (LocalTime) get(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>done.v_daylimit.dayworktime</code>.
|
* Setter for <code>done.v_daylimit.dayworktime</code>.
|
||||||
*/
|
*/
|
||||||
public void setDayworktime(String value) {
|
public void setDayworktime(LocalTime value) {
|
||||||
set(2, value);
|
set(2, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>done.v_daylimit.dayworktime</code>.
|
* Getter for <code>done.v_daylimit.dayworktime</code>.
|
||||||
*/
|
*/
|
||||||
public String getDayworktime() {
|
public LocalTime getDayworktime() {
|
||||||
return (String) get(2);
|
return (LocalTime) get(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>done.v_daylimit.breaks</code>.
|
* Setter for <code>done.v_daylimit.breaks</code>.
|
||||||
*/
|
*/
|
||||||
public void setBreaks(String value) {
|
public void setBreaks(YearToSecond value) {
|
||||||
set(3, value);
|
set(3, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>done.v_daylimit.breaks</code>.
|
* Getter for <code>done.v_daylimit.breaks</code>.
|
||||||
*/
|
*/
|
||||||
public String getBreaks() {
|
public YearToSecond getBreaks() {
|
||||||
return (String) get(3);
|
return (YearToSecond) get(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,32 +113,32 @@ public class VDaylimitRecord extends TableRecordImpl<VDaylimitRecord> implements
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Row6<String, String, String, String, LocalDate, Integer> fieldsRow() {
|
public Row6<LocalTime, LocalTime, LocalTime, YearToSecond, LocalDate, Integer> fieldsRow() {
|
||||||
return (Row6) super.fieldsRow();
|
return (Row6) super.fieldsRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Row6<String, String, String, String, LocalDate, Integer> valuesRow() {
|
public Row6<LocalTime, LocalTime, LocalTime, YearToSecond, LocalDate, Integer> valuesRow() {
|
||||||
return (Row6) super.valuesRow();
|
return (Row6) super.valuesRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<String> field1() {
|
public Field<LocalTime> field1() {
|
||||||
return VDaylimit.V_DAYLIMIT.DAYTIME_FROM;
|
return VDaylimit.V_DAYLIMIT.DAYTIME_FROM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<String> field2() {
|
public Field<LocalTime> field2() {
|
||||||
return VDaylimit.V_DAYLIMIT.DAYTIME_UNTIL;
|
return VDaylimit.V_DAYLIMIT.DAYTIME_UNTIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<String> field3() {
|
public Field<LocalTime> field3() {
|
||||||
return VDaylimit.V_DAYLIMIT.DAYWORKTIME;
|
return VDaylimit.V_DAYLIMIT.DAYWORKTIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<String> field4() {
|
public Field<YearToSecond> field4() {
|
||||||
return VDaylimit.V_DAYLIMIT.BREAKS;
|
return VDaylimit.V_DAYLIMIT.BREAKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,22 +153,22 @@ public class VDaylimitRecord extends TableRecordImpl<VDaylimitRecord> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String component1() {
|
public LocalTime component1() {
|
||||||
return getDaytimeFrom();
|
return getDaytimeFrom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String component2() {
|
public LocalTime component2() {
|
||||||
return getDaytimeUntil();
|
return getDaytimeUntil();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String component3() {
|
public LocalTime component3() {
|
||||||
return getDayworktime();
|
return getDayworktime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String component4() {
|
public YearToSecond component4() {
|
||||||
return getBreaks();
|
return getBreaks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,22 +183,22 @@ public class VDaylimitRecord extends TableRecordImpl<VDaylimitRecord> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String value1() {
|
public LocalTime value1() {
|
||||||
return getDaytimeFrom();
|
return getDaytimeFrom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String value2() {
|
public LocalTime value2() {
|
||||||
return getDaytimeUntil();
|
return getDaytimeUntil();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String value3() {
|
public LocalTime value3() {
|
||||||
return getDayworktime();
|
return getDayworktime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String value4() {
|
public YearToSecond value4() {
|
||||||
return getBreaks();
|
return getBreaks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,25 +213,25 @@ public class VDaylimitRecord extends TableRecordImpl<VDaylimitRecord> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VDaylimitRecord value1(String value) {
|
public VDaylimitRecord value1(LocalTime value) {
|
||||||
setDaytimeFrom(value);
|
setDaytimeFrom(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VDaylimitRecord value2(String value) {
|
public VDaylimitRecord value2(LocalTime value) {
|
||||||
setDaytimeUntil(value);
|
setDaytimeUntil(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VDaylimitRecord value3(String value) {
|
public VDaylimitRecord value3(LocalTime value) {
|
||||||
setDayworktime(value);
|
setDayworktime(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VDaylimitRecord value4(String value) {
|
public VDaylimitRecord value4(YearToSecond value) {
|
||||||
setBreaks(value);
|
setBreaks(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -247,7 +249,7 @@ public class VDaylimitRecord extends TableRecordImpl<VDaylimitRecord> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VDaylimitRecord values(String value1, String value2, String value3, String value4, LocalDate value5, Integer value6) {
|
public VDaylimitRecord values(LocalTime value1, LocalTime value2, LocalTime value3, YearToSecond value4, LocalDate value5, Integer value6) {
|
||||||
value1(value1);
|
value1(value1);
|
||||||
value2(value2);
|
value2(value2);
|
||||||
value3(value3);
|
value3(value3);
|
||||||
@ -271,7 +273,7 @@ public class VDaylimitRecord extends TableRecordImpl<VDaylimitRecord> implements
|
|||||||
/**
|
/**
|
||||||
* Create a detached, initialised VDaylimitRecord
|
* Create a detached, initialised VDaylimitRecord
|
||||||
*/
|
*/
|
||||||
public VDaylimitRecord(String daytimeFrom, String daytimeUntil, String dayworktime, String breaks, LocalDate day, Integer fkLogin) {
|
public VDaylimitRecord(LocalTime daytimeFrom, LocalTime daytimeUntil, LocalTime dayworktime, YearToSecond breaks, LocalDate day, Integer fkLogin) {
|
||||||
super(VDaylimit.V_DAYLIMIT);
|
super(VDaylimit.V_DAYLIMIT);
|
||||||
|
|
||||||
setDaytimeFrom(daytimeFrom);
|
setDaytimeFrom(daytimeFrom);
|
||||||
|
@ -31,20 +31,20 @@ grant select,insert,update,delete on done.t_freetime to timetrack;
|
|||||||
create view done.v_daylimit as
|
create view done.v_daylimit as
|
||||||
with x(dayworktime, day, fk_login) as (
|
with x(dayworktime, day, fk_login) as (
|
||||||
select coalesce(time_until - time_from, '0'::interval),
|
select coalesce(time_until - time_from, '0'::interval),
|
||||||
to_char(time_from, 'DD.MM.YYYY')::date,
|
time_from,
|
||||||
fk_login
|
fk_login
|
||||||
from done.t_done
|
from done.t_done
|
||||||
), y(daytime_from, daytime_until, day, fk_login) as (
|
), y(daytime_from, daytime_until, day, fk_login) as (
|
||||||
select min(time_from), max(time_until),
|
select min(time_from), max(time_until),
|
||||||
to_char(time_from, 'DD.MM.YYYY')::date,
|
time_from,
|
||||||
fk_login
|
fk_login
|
||||||
from done.t_done
|
from done.t_done
|
||||||
group by to_char(time_from, 'DD.MM.YYYY')::date, fk_login
|
group by time_from, fk_login
|
||||||
) select to_char(y.daytime_from, 'HH24:MI') as daytime_from,
|
) select y.daytime_from::time,
|
||||||
to_char(y.daytime_until, 'HH24:MI') as daytime_until,
|
y.daytime_until::time,
|
||||||
to_char(sum(x.dayworktime), 'HH24:MI') as dayworktime,
|
sum(x.dayworktime)::time as dayworktime,
|
||||||
to_char(y.daytime_until - y.daytime_from - sum(x.dayworktime), 'HH24:MI') as breaks,
|
y.daytime_until - y.daytime_from - sum(x.dayworktime) as breaks,
|
||||||
to_char(y.day, 'DD.MM.YYYY')::date as day,
|
y.day::date,
|
||||||
y.fk_login
|
y.fk_login
|
||||||
from x
|
from x
|
||||||
left join y on y.day = x.day and y.fk_login = x.fk_login
|
left join y on y.day = x.day and y.fk_login = x.fk_login
|
||||||
@ -54,7 +54,7 @@ with x(dayworktime, day, fk_login) as (
|
|||||||
grant select on done.v_daylimit to timetrack;
|
grant select on done.v_daylimit to timetrack;
|
||||||
|
|
||||||
create view done.v_current_overtime as
|
create view done.v_current_overtime as
|
||||||
select x.worktime_offset + sum(l.dayworktime::time - r.required) as overtime,
|
select x.worktime_offset + sum(l.dayworktime - r.required) as overtime,
|
||||||
to_char(now(), 'DD.MM.YYYY HH24:MI') as impact,
|
to_char(now(), 'DD.MM.YYYY HH24:MI') as impact,
|
||||||
x.fk_login
|
x.fk_login
|
||||||
from done.t_overtime x
|
from done.t_overtime x
|
||||||
|
Reference in New Issue
Block a user