new project block - codegen damaged...
This commit is contained in:
@@ -48,6 +48,31 @@ create table done.t_favorite (
|
||||
fk_billing integer references done.t_billing(pk)
|
||||
);
|
||||
|
||||
create table done.t_required_worktime (
|
||||
pk_required_worktime int primary key generated always as identity,
|
||||
required_minutes int not null default 480,
|
||||
day date not null,
|
||||
reason text,
|
||||
fk_login int not null references profile.t_login(pk),
|
||||
unique(day, fk_login)
|
||||
);
|
||||
|
||||
create table done.t_overtime (
|
||||
pk_overtime int primary key generated always as identity,
|
||||
overtime_minutes int not null,
|
||||
impact timestamp without time zone not null,
|
||||
fk_login int not null unique references profile.t_login(pk)
|
||||
);
|
||||
|
||||
create table done.t_freetime (
|
||||
pk_freetime int primary key generated always as identity,
|
||||
day date not null,
|
||||
required_worktime time without time zone not null default '0:0'::time,
|
||||
reason text,
|
||||
fk_login int not null references profile.t_login(pk),
|
||||
unique(day, fk_login)
|
||||
);
|
||||
|
||||
create view done.v_favorite as
|
||||
select f.pk_favorite, f.fk_login, p.name as project, m.name as module, j.name as job, b.name as billing
|
||||
from done.t_favorite f
|
||||
@@ -233,6 +258,52 @@ left join done.t_job j on j.pk = d.fk_job
|
||||
left join done.t_billing b on b.pk = d.fk_billing
|
||||
group by t.day, p.name, m.name, j.name, b.shortcut, b.csskey, t.fk_login;
|
||||
|
||||
create view done.v_daylimit as
|
||||
with x(dayworktime, day, fk_login) as (
|
||||
select coalesce(time_until - time_from, '0'::interval),
|
||||
time_from,
|
||||
fk_login
|
||||
from done.t_done
|
||||
), y(daytime_from, daytime_until, day, fk_login) as (
|
||||
select min(time_from), max(time_until),
|
||||
time_from,
|
||||
fk_login
|
||||
from done.t_done
|
||||
group by time_from, fk_login
|
||||
) select y.daytime_from::time,
|
||||
y.daytime_until::time,
|
||||
sum(x.dayworktime)::time as dayworktime,
|
||||
y.daytime_until - y.daytime_from - sum(x.dayworktime) as breaks,
|
||||
y.day::date,
|
||||
y.fk_login
|
||||
from x
|
||||
left join y on y.day = x.day and y.fk_login = x.fk_login
|
||||
group by y.daytime_from, y.daytime_until, y.day, y.fk_login
|
||||
order by y.day desc;
|
||||
|
||||
create or replace view done.v_current_overtime as
|
||||
select x.overtime_minutes + sum(extract(minute from l.dayworktime) - r.required_minutes) as overtime,
|
||||
to_char(now(), 'DD.MM.YYYY HH24:MI') as impact,
|
||||
x.fk_login
|
||||
from done.t_overtime x
|
||||
left join done.v_daylimit l on l.fk_login = x.fk_login and l.day >= x.impact
|
||||
left join done.t_required_worktime r on r.fk_login = x.fk_login and r.day = l.day
|
||||
where l.day < now()
|
||||
group by x.overtime_minutes, x.fk_login;
|
||||
|
||||
create or replace view done.v_day as
|
||||
with x(dayworktime, day, fk_login, required, starttime, endtime) as (
|
||||
select sum(d.dayworktime), d.day, d.fk_login, make_interval(mins => r.required_minutes),
|
||||
min(d.daytime_from), max(d.daytime_until)
|
||||
from done.v_daylimit d
|
||||
left join done.t_required_worktime r on r.day = d.day and r.fk_login = d.fk_login
|
||||
group by d.day, d.fk_login, r.required_minutes
|
||||
) select day, starttime, endtime, dayworktime as worktime,
|
||||
endtime - starttime - dayworktime as breaktime,
|
||||
dayworktime - required as day_overtime, fk_login
|
||||
from x
|
||||
order by day desc, fk_login;
|
||||
|
||||
copy done.t_billing (lastchange, pk, name, shortcut, csskey) from stdin;
|
||||
2021-03-05 19:37:07.12832 1 WP2 (eucs) - Opal/Mica/..., REST WP2 WP2
|
||||
2021-03-05 19:37:07.12832 2 WP4 (eucs) - Square² WP4 WP4
|
||||
@@ -321,18 +392,25 @@ grant select,insert,delete,update on table done.t_job to timetrack;
|
||||
grant select,insert,delete,update on table done.t_module to timetrack;
|
||||
grant select,insert,delete,update on table done.t_project to timetrack;
|
||||
grant select,insert,delete,update on table done.t_favorite to timetrack;
|
||||
grant select on table done.v_favorite to timetrack;
|
||||
grant select on table done.v_billing to timetrack;
|
||||
grant select on table done.v_done to timetrack;
|
||||
grant select on table done.v_duration to timetrack;
|
||||
grant select on table done.v_daily to timetrack;
|
||||
grant select on table done.v_daylimits to timetrack;
|
||||
grant select on table done.v_daysummary to timetrack;
|
||||
grant select on table done.v_hamstersummary to timetrack;
|
||||
grant select on table done.v_job to timetrack;
|
||||
grant select on table done.v_module to timetrack;
|
||||
grant select on table done.v_project to timetrack;
|
||||
grant select on table done.v_tasklist to timetrack;
|
||||
grant select on table done.v_timelength to timetrack;
|
||||
grant select on table done.v_totalofday to timetrack;
|
||||
grant select on table done.v_worktime to timetrack;
|
||||
grant select,insert,update,delete on done.t_required_worktime to timetrack;
|
||||
grant select,insert,update on done.t_overtime to timetrack;
|
||||
grant select,insert,update,delete on done.t_freetime to timetrack;
|
||||
|
||||
grant select on done.v_favorite to timetrack;
|
||||
grant select on done.v_billing to timetrack;
|
||||
grant select on done.v_done to timetrack;
|
||||
grant select on done.v_duration to timetrack;
|
||||
grant select on done.v_daily to timetrack;
|
||||
grant select on done.v_daylimits to timetrack;
|
||||
grant select on done.v_daysummary to timetrack;
|
||||
grant select on done.v_hamstersummary to timetrack;
|
||||
grant select on done.v_job to timetrack;
|
||||
grant select on done.v_module to timetrack;
|
||||
grant select on done.v_project to timetrack;
|
||||
grant select on done.v_tasklist to timetrack;
|
||||
grant select on done.v_timelength to timetrack;
|
||||
grant select on done.v_totalofday to timetrack;
|
||||
grant select on done.v_worktime to timetrack;
|
||||
grant select on done.v_daylimit to timetrack;
|
||||
grant select on done.v_current_overtime to timetrack;
|
||||
grant select on done.v_day to timetrack;
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
create table done.t_required_worktime (
|
||||
pk_required_worktime int primary key generated always as identity,
|
||||
required_minutes int not null default 480,
|
||||
day date not null,
|
||||
reason text,
|
||||
fk_login int not null references profile.t_login(pk),
|
||||
unique(day, fk_login)
|
||||
);
|
||||
|
||||
grant select,insert,update,delete on done.t_required_worktime to timetrack;
|
||||
|
||||
create table done.t_overtime (
|
||||
pk_overtime int primary key generated always as identity,
|
||||
overtime_minutes int not null,
|
||||
impact timestamp without time zone not null,
|
||||
fk_login int not null unique references profile.t_login(pk)
|
||||
);
|
||||
|
||||
grant select,insert,update on done.t_overtime to timetrack;
|
||||
|
||||
create table done.t_freetime (
|
||||
pk_freetime int primary key generated always as identity,
|
||||
day date not null,
|
||||
required_worktime time without time zone not null default '0:0'::time,
|
||||
reason text,
|
||||
fk_login int not null references profile.t_login(pk),
|
||||
unique(day, fk_login)
|
||||
);
|
||||
|
||||
grant select,insert,update,delete on done.t_freetime to timetrack;
|
||||
|
||||
create view done.v_daylimit as
|
||||
with x(dayworktime, day, fk_login) as (
|
||||
select coalesce(time_until - time_from, '0'::interval),
|
||||
time_from,
|
||||
fk_login
|
||||
from done.t_done
|
||||
), y(daytime_from, daytime_until, day, fk_login) as (
|
||||
select min(time_from), max(time_until),
|
||||
time_from,
|
||||
fk_login
|
||||
from done.t_done
|
||||
group by time_from, fk_login
|
||||
) select y.daytime_from::time,
|
||||
y.daytime_until::time,
|
||||
sum(x.dayworktime)::time as dayworktime,
|
||||
y.daytime_until - y.daytime_from - sum(x.dayworktime) as breaks,
|
||||
y.day::date,
|
||||
y.fk_login
|
||||
from x
|
||||
left join y on y.day = x.day and y.fk_login = x.fk_login
|
||||
group by y.daytime_from, y.daytime_until, y.day, y.fk_login
|
||||
order by y.day desc;
|
||||
|
||||
grant select on done.v_daylimit to timetrack;
|
||||
|
||||
create or replace view done.v_current_overtime as
|
||||
select x.overtime_minutes + sum(extract(minute from l.dayworktime) - r.required_minutes) as overtime,
|
||||
to_char(now(), 'DD.MM.YYYY HH24:MI') as impact,
|
||||
x.fk_login
|
||||
from done.t_overtime x
|
||||
left join done.v_daylimit l on l.fk_login = x.fk_login and l.day >= x.impact
|
||||
left join done.t_required_worktime r on r.fk_login = x.fk_login and r.day = l.day
|
||||
where l.day < now()
|
||||
group by x.overtime_minutes, x.fk_login;
|
||||
|
||||
grant select on done.v_current_overtime to timetrack;
|
||||
|
||||
create or replace view done.v_day as
|
||||
with x(dayworktime, day, fk_login, required, starttime, endtime) as (
|
||||
select sum(d.dayworktime), d.day, d.fk_login, make_interval(mins => r.required_minutes),
|
||||
min(d.daytime_from), max(d.daytime_until)
|
||||
from done.v_daylimit d
|
||||
left join done.t_required_worktime r on r.day = d.day and r.fk_login = d.fk_login
|
||||
group by d.day, d.fk_login, r.required_minutes
|
||||
) select day, starttime, endtime, dayworktime as worktime,
|
||||
endtime - starttime - dayworktime as breaktime,
|
||||
dayworktime - required as day_overtime, fk_login
|
||||
from x
|
||||
order by day desc, fk_login;
|
||||
|
||||
grant select on done.v_day to timetrack;
|
||||
|
||||
create or replace view done.v_version as select 20240105 as version;
|
||||
@@ -14,7 +14,8 @@ create table profile.t_profile (
|
||||
lastchange timestamp without time zone default now(),
|
||||
pk_profile integer not null primary key generated always as identity,
|
||||
username text not null unique,
|
||||
theme text default 'light'::text not null
|
||||
theme text default 'light'::text not null,
|
||||
column dynamic_css text
|
||||
);
|
||||
|
||||
create table profile.t_role (
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
alter table profile.t_profile add column dynamic_css text;
|
||||
|
||||
78
src/main/resources/project.sql
Normal file
78
src/main/resources/project.sql
Normal file
@@ -0,0 +1,78 @@
|
||||
create schema project;
|
||||
|
||||
create type project.enum_phase as enum ('concept', 'development', 'test', 'postponed');
|
||||
|
||||
create table project.t_funder (
|
||||
created timestamp without time zone default now(),
|
||||
pk_funder int not null primary key generated always as identity,
|
||||
name text not null unique,
|
||||
description text
|
||||
);
|
||||
|
||||
create table project.t_project (
|
||||
created timestamp without time zone default now(),
|
||||
pk_project int not null primary key generated always as identity,
|
||||
name text not null,
|
||||
description text,
|
||||
fk_funder int references project.t_funder
|
||||
);
|
||||
|
||||
create table project.t_workpackage (
|
||||
created timestamp without time zone default now(),
|
||||
pk_workpackage int not null primary key generated always as identity,
|
||||
fk_project int references project.t_project(pk_project),
|
||||
name text not null,
|
||||
description text,
|
||||
milestone_url text,
|
||||
contract_url text,
|
||||
planned_duedate date
|
||||
);
|
||||
|
||||
create table project.t_bundle (
|
||||
created timestamp without time zone default now(),
|
||||
pk_bundle int not null primary key generated always as identity,
|
||||
name text not null unique,
|
||||
description text
|
||||
);
|
||||
|
||||
create table project.t_app (
|
||||
created timestamp without time zone default now(),
|
||||
pk_app int not null primary key generated always as identity,
|
||||
fk_bundle int references project.t_bundle(pk_bundle),
|
||||
basic_functionality text,
|
||||
name text,
|
||||
description text,
|
||||
fk_replaced_by_app int references project.t_app(pk_app),
|
||||
repository_url text
|
||||
);
|
||||
|
||||
create table project.t_workpackage_app (
|
||||
created timestamp without time zone default now(),
|
||||
pk_workpackage_app int not null primary key generated always as identity,
|
||||
fk_workpackage int not null references project.t_workpackage(pk_workpackage),
|
||||
fk_app int not null references project.t_app(pk_app),
|
||||
unique(fk_workpackage, fk_app)
|
||||
);
|
||||
|
||||
create table project.t_progress (
|
||||
created timestamp without time zone default now(),
|
||||
pk_progress int not null primary key generated always as identity,
|
||||
progress numeric(2, 0) not null,
|
||||
phase project.enum_phase
|
||||
);
|
||||
|
||||
create view project.v_bundle_apps as
|
||||
select b.name, string_agg(a.name, ',')
|
||||
from project.t_bundle b
|
||||
left join project.t_app a on a.fk_bundle = b.pk_bundle
|
||||
group by b.name;
|
||||
|
||||
grant select,insert,update,delete on project.t_funder to timetrack;
|
||||
grant select,insert,update,delete on project.t_project to timetrack;
|
||||
grant select,insert,update,delete on project.t_workpackage to timetrack;
|
||||
grant select,insert,update,delete on project.t_bundle to timetrack;
|
||||
grant select,insert,update,delete on project.t_app to timetrack;
|
||||
grant select,insert,update,delete on project.t_workpackage_app to timetrack;
|
||||
grant select,insert,update,delete on project.t_progress to timetrack;
|
||||
|
||||
grant select on project.v_bundle_apps to timetrack;
|
||||
6
src/main/resources/public.sql
Normal file
6
src/main/resources/public.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
create or replace view public.v_version as
|
||||
select 20260114 as version;
|
||||
|
||||
grant usage on schema public to timetrack;
|
||||
|
||||
grant select on public.v_version to timetrack;
|
||||
@@ -5,4 +5,6 @@ begin;
|
||||
\i done_ext.sql
|
||||
\i contact.sql
|
||||
\i note.sql
|
||||
\i project.sql
|
||||
\i public.sql
|
||||
commit;
|
||||
|
||||
Reference in New Issue
Block a user