/usr/share/gforge/db/timetracking-init.sql is in gforge-db-postgresql 5.1.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | CREATE SEQUENCE rep_time_category_time_code_seq ;
CREATE TABLE rep_time_category (
time_code integer DEFAULT nextval('rep_time_category_time_code_seq'::text) UNIQUE,
category_name text
);
CREATE TABLE rep_time_tracking (
week int not null,
report_date int not null,
user_id int not null,
project_task_id int not null,
time_code int not null CONSTRAINT reptimetrk_timecode REFERENCES rep_time_category(time_code),
hours float not null
);
-- CREATE UNIQUE INDEX reptimetrk_weekusrtskcde ON
-- rep_time_tracking (week,user_id,project_task_id,time_code);
CREATE INDEX reptimetracking_userdate ON
rep_time_tracking (user_id,week);
INSERT INTO rep_time_category VALUES ('1','Coding');
INSERT INTO rep_time_category VALUES ('2','Testing');
INSERT INTO rep_time_category VALUES ('3','Meeting');
SELECT setval('rep_time_category_time_code_seq',(SELECT max(time_code) FROM rep_time_category));
-- added users
CREATE TABLE rep_users_added_daily (
day int not null primary key,
added int not null default 0
);
CREATE TABLE rep_users_added_weekly (
week int not null primary key,
added int not null default 0
);
CREATE TABLE rep_users_added_monthly (
month int not null primary key,
added int not null default 0
);
-- cumulative users
CREATE TABLE rep_users_cum_daily (
day int not null primary key,
total int not null default 0
);
CREATE TABLE rep_users_cum_weekly (
week int not null primary key,
total int not null default 0
);
CREATE TABLE rep_users_cum_monthly (
month int not null primary key,
total int not null default 0
);
-- added groups
CREATE TABLE rep_groups_added_daily (
day int not null primary key,
added int not null default 0
);
CREATE TABLE rep_groups_added_weekly (
week int not null primary key,
added int not null default 0
);
CREATE TABLE rep_groups_added_monthly (
month int not null primary key,
added int not null default 0
);
-- cumulative groups
CREATE TABLE rep_groups_cum_daily (
day int not null primary key,
total int not null default 0
);
CREATE TABLE rep_groups_cum_weekly (
week int not null primary key,
total int not null default 0
);
CREATE TABLE rep_groups_cum_monthly (
month int not null primary key,
total int not null default 0
);
-- per-user activity
CREATE TABLE rep_user_act_daily (
user_id int not null,
day int not null,
tracker_opened int not null,
tracker_closed int not null,
forum int not null,
docs int not null,
cvs_commits int not null,
tasks_opened int not null,
tasks_closed int not null,
PRIMARY KEY (user_id,day)
);
CREATE TABLE rep_user_act_weekly (
user_id int not null,
week int not null,
tracker_opened int not null,
tracker_closed int not null,
forum int not null,
docs int not null,
cvs_commits int not null,
tasks_opened int not null,
tasks_closed int not null,
PRIMARY KEY (user_id,week)
);
CREATE TABLE rep_user_act_monthly (
user_id int not null,
month int not null,
tracker_opened int not null,
tracker_closed int not null,
forum int not null,
docs int not null,
cvs_commits int not null,
tasks_opened int not null,
tasks_closed int not null,
PRIMARY KEY (user_id,month)
);
CREATE VIEW rep_user_act_oa_vw AS
SELECT user_id,
sum(tracker_opened) AS tracker_opened,
sum(tracker_closed) AS tracker_closed,
sum(forum) AS forum,
sum(docs) AS docs,
sum(cvs_commits) AS cvs_commits,
sum(tasks_opened) AS tasks_opened,
sum(tasks_closed) AS tasks_closed
FROM rep_user_act_monthly
GROUP BY user_id;
-- per-project activity
CREATE TABLE rep_group_act_daily (
group_id int not null,
day int not null,
tracker_opened int not null,
tracker_closed int not null,
forum int not null,
docs int not null,
downloads int not null,
cvs_commits int not null,
tasks_opened int not null,
tasks_closed int not null,
PRIMARY KEY (group_id,day)
);
CREATE INDEX repgroupactdaily_day ON rep_group_act_daily(day);
CREATE TABLE rep_group_act_weekly (
group_id int not null,
week int not null,
tracker_opened int not null,
tracker_closed int not null,
forum int not null,
docs int not null,
downloads int not null,
cvs_commits int not null,
tasks_opened int not null,
tasks_closed int not null,
PRIMARY KEY (group_id,week)
);
CREATE INDEX repgroupactweekly_week ON rep_group_act_weekly(week);
CREATE TABLE rep_group_act_monthly (
group_id int not null,
month int not null,
tracker_opened int not null,
tracker_closed int not null,
forum int not null,
docs int not null,
downloads int not null,
cvs_commits int not null,
tasks_opened int not null,
tasks_closed int not null,
PRIMARY KEY (group_id,month)
);
CREATE INDEX repgroupactmonthly_month ON rep_group_act_monthly(month);
CREATE VIEW rep_group_act_oa_vw AS
SELECT group_id,
sum(tracker_opened) AS tracker_opened,
sum(tracker_closed) AS tracker_closed,
sum(forum) AS forum,
sum(docs) AS docs,
sum(downloads) AS downloads,
sum(cvs_commits) AS cvs_commits,
sum(tasks_opened) AS tasks_opened,
sum(tasks_closed) AS tasks_closed
FROM rep_group_act_monthly
GROUP BY group_id;
-- overall activity
CREATE VIEW rep_site_act_daily_vw AS
SELECT day,
sum(tracker_opened) AS tracker_opened,
sum(tracker_closed) AS tracker_closed,
sum(forum) AS forum,
sum(docs) AS docs,
sum(downloads) AS downloads,
sum(cvs_commits) AS cvs_commits,
sum(tasks_opened) AS tasks_opened,
sum(tasks_closed) AS tasks_closed
FROM rep_group_act_daily
GROUP BY day;
CREATE VIEW rep_site_act_weekly_vw AS
SELECT week,
sum(tracker_opened) AS tracker_opened,
sum(tracker_closed) AS tracker_closed,
sum(forum) AS forum,
sum(docs) AS docs,
sum(downloads) AS downloads,
sum(cvs_commits) AS cvs_commits,
sum(tasks_opened) AS tasks_opened,
sum(tasks_closed) AS tasks_closed
FROM rep_group_act_weekly
GROUP BY week;
CREATE VIEW rep_site_act_monthly_vw AS
SELECT month,
sum(tracker_opened) AS tracker_opened,
sum(tracker_closed) AS tracker_closed,
sum(forum) AS forum,
sum(docs) AS docs,
sum(downloads) AS downloads,
sum(cvs_commits) AS cvs_commits,
sum(tasks_opened) AS tasks_opened,
sum(tasks_closed) AS tasks_closed
FROM rep_group_act_monthly
GROUP BY month;
|