mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-13 07:24:05 +00:00
server-side. Generic and reusable by the next suite: setup_testinstance.php (--setup/--verify, delegating the rebuild to paolos db_setup.sh), tasks/db.js, tasks/sshTunnel.js, tools/dbCheck.js and cypress.config.js carry no suite-specific knowledge. A suite adds tools/checks/<name>.js, suites/<name>.js and its own task file. Fixture state resets over a direct Postgres connection through an SSH tunnel the runner opens itself. Tests: 37 passing, 5 pending, 1 failing. Pending are opt-in (Freigabe sends real mail; the Frist config is off). The failing spec is left red on purpose: it documents that getLvGesamtNoten filters freigabedatum < NOW(), so the read path hides un-freigegebene notes while the write path uses the unfiltered getter. Not really certain if that is a feature or a bug; Working on more actual testsuites now that the setup is running as intended;
37 lines
1.4 KiB
PL/PgSQL
37 lines
1.4 KiB
PL/PgSQL
CREATE OR REPLACE FUNCTION NearestWintersemester(var_entfernung integer) RETURNS varchar(32) AS $$
|
|
DECLARE res varchar(32);
|
|
BEGIN
|
|
WITH nearestws AS
|
|
(
|
|
SELECT studiensemester_kurzbz, start FROM public.tbl_studiensemester WHERE studiensemester_kurzbz LIKE 'W%' AND ende>=now() ORDER BY start DESC LIMIT 1
|
|
)
|
|
SELECT studiensemester_kurzbz into res
|
|
FROM
|
|
(
|
|
SELECT studiensemester_kurzbz, 0 as "entfernung" FROM nearestws
|
|
UNION
|
|
SELECT studiensemester_kurzbz, rank() over(order by start desc) as "entfernung" FROM public.tbl_studiensemester where start>(SELECT start FROM nearestws)
|
|
UNION
|
|
SELECT studiensemester_kurzbz, (-1 * rank() over(order by start desc)) as "entfernung" FROM public.tbl_studiensemester WHERE start<(SELECT start FROM nearestws)
|
|
) x where entfernung=var_entfernung;
|
|
|
|
return res;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
CREATE OR REPLACE FUNCTION CurrentSemester() RETURNS varchar(32) AS $$
|
|
DECLARE res varchar(32);
|
|
BEGIN
|
|
SELECT studiensemester_kurzbz into res FROM public.tbl_studiensemester WHERE start<=now() AND ende>=now() ORDER BY start DESC LIMIT 1;
|
|
return res;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
CREATE OR REPLACE FUNCTION LastActiveSemester() RETURNS varchar(32) AS $$
|
|
DECLARE res varchar(32);
|
|
BEGIN
|
|
SELECT studiensemester_kurzbz into res FROM public.tbl_studiensemester WHERE start<=now() ORDER BY start DESC LIMIT 1;
|
|
return res;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|