Skip to content

Commit

Permalink
Расширена и покрыта тестами /register: можно передать желаемый уровен…
Browse files Browse the repository at this point in the history
…ь привиллегий (#15)

1)  Расширена и покрыта тестами /register: можно передать желаемый уровень привиллегий 
2) В очередной раз изменены настройки форматтера
3) Контроллеры переведены на транзакции
4) Некоторый фикс postgres_helper: теперь не привязан к рефлективным типам
  • Loading branch information
sabudilovskiy authored May 19, 2023
1 parent 2bab424 commit e96adfd
Show file tree
Hide file tree
Showing 189 changed files with 1,956 additions and 1,016 deletions.
5 changes: 4 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ BasedOnStyle: Google
IndentWidth: 4
TabWidth: 4
UseTab: Never
BreakBeforeBraces: Attach
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
Expand All @@ -14,3 +14,6 @@ SpaceAfterCStyleCast: true
DerivePointerAlignment: false
AlignTrailingComments: true
SortIncludes: true
BraceWrapping:
AfterClass: true
AfterFunction: true
2 changes: 2 additions & 0 deletions .gen/objs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ src/models/subgroup/postgre.hpp
src/models/subgroup/parse.hpp
src/models/subgroup/parse.cpp
src/models/subgroup/all.hpp
src/models/register_request/type.hpp
src/models/register_request/fwd.hpp
src/models/lesson_week_type/type.hpp
src/models/lesson_week_type/serialize.hpp
src/models/lesson_week_type/serialize.cpp
Expand Down
7 changes: 6 additions & 1 deletion api/views/register/RequestV1.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
properties:
user_credential:
$ref: '../../types/UserCredentialV1.yaml'
user_type:
desired_type:
$ref: '../../types/UserTypeV1.yaml'
description:
type: string
description: Дополнительная информация для администраторов при регистрации (в рамках запроса привиллегий преподавателя или администратора)
required:
- user_credential
6 changes: 4 additions & 2 deletions benchs/hello_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

#include "views/hello/view.hpp"

void HelloBenchmark(benchmark::State& state) {
void HelloBenchmark(benchmark::State& state)
{
userver::engine::RunStandalone([&] {
constexpr std::string_view kNames[] = {"userver", "is", "awesome", "!"};
std::uint64_t i = 0;

for (auto _ : state) {
for (auto _ : state)
{
const auto name = kNames[i++ % std::size(kNames)];
auto result = service_template::SayHelloTo(
name, service_template::UserType::kKnown);
Expand Down
4 changes: 2 additions & 2 deletions postgresql/data/initial_data_auth_admin.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INSERT INTO vsu_timetable.user(login, password, id)
INSERT INTO timetable_vsu.user(login, password, id)
VALUES('some_admin', 'admin_password', '333111c7-9654-4814-b36b-7d39c1ddded2');

INSERT INTO vsu_timetable."admin"
INSERT INTO timetable_vsu."admin"
(id, id_user)
VALUES('000111c7-9654-4814-b36b-7d39c1ddded2', '333111c7-9654-4814-b36b-7d39c1ddded2');
2 changes: 1 addition & 1 deletion postgresql/data/initial_data_auth_admin_token.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
INSERT INTO vsu_timetable.token
INSERT INTO timetable_vsu.token
(id, id_user)
VALUES('333111c7-9654-4814-b36b-7d39c1ddded2', '333111c7-9654-4814-b36b-7d39c1ddded2');
2 changes: 1 addition & 1 deletion postgresql/data/initial_data_auth_root.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
INSERT INTO vsu_timetable.user(login, password, id)
INSERT INTO timetable_vsu.user(login, password, id)
VALUES('root', 'secret-password', 'dddddddd-dddd-dddd-dddd-dddddddddddd');
2 changes: 1 addition & 1 deletion postgresql/data/initial_data_auth_root_token.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
INSERT INTO vsu_timetable.token
INSERT INTO timetable_vsu.token
(id, id_user)
VALUES('dddddddd-dddd-dddd-dddd-dddddddddddd', 'dddddddd-dddd-dddd-dddd-dddddddddddd');
10 changes: 5 additions & 5 deletions postgresql/data/initial_data_auth_teacher.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
INSERT INTO vsu_timetable.faculty
INSERT INTO timetable_vsu.faculty
(id, "name")
VALUES('999111c7-9654-4814-bbbb-7d39c1ddded2', '');

INSERT INTO vsu_timetable.department
INSERT INTO timetable_vsu.department
(id, "name", id_faculty)
VALUES('555111c7-9654-4814-cccc-7d39c1ddded2', '', '999111c7-9654-4814-bbbb-7d39c1ddded2');

INSERT INTO vsu_timetable.teacher
INSERT INTO timetable_vsu.teacher
(id, fio, bio, id_department)
VALUES('222111c7-9654-4814-dddd-7d39c1ddded2', '', '', '555111c7-9654-4814-cccc-7d39c1ddded2');

INSERT INTO vsu_timetable.user(login, password, id)
INSERT INTO timetable_vsu.user(login, password, id)
VALUES('some_teacher', 'teacher_password', '222111c7-9654-4814-b36b-7d39c1ddded2');

INSERT INTO vsu_timetable.teacher_link
INSERT INTO timetable_vsu.teacher_link
(id, id_user, id_teacher)
VALUES('666111c7-9654-4814-b36b-7d39c1ddded2', '222111c7-9654-4814-b36b-7d39c1ddded2', '222111c7-9654-4814-dddd-7d39c1ddded2');
2 changes: 1 addition & 1 deletion postgresql/data/initial_data_auth_teacher_token.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
INSERT INTO vsu_timetable.token
INSERT INTO timetable_vsu.token
(id, id_user)
VALUES('222111c7-9654-4814-b36b-7d39c1ddded2', '222111c7-9654-4814-b36b-7d39c1ddded2');
2 changes: 1 addition & 1 deletion postgresql/data/initial_data_auth_user.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
INSERT INTO vsu_timetable.user(login, password, id)
INSERT INTO timetable_vsu.user(login, password, id)
VALUES('some_user', 'user_password', '111111c7-9654-4814-b36b-7d39c1ddded2');
2 changes: 1 addition & 1 deletion postgresql/data/initial_data_auth_user_token.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
INSERT INTO vsu_timetable.token
INSERT INTO timetable_vsu.token
(id, id_user)
VALUES('111111c7-9654-4814-b36b-7d39c1ddded2', '111111c7-9654-4814-b36b-7d39c1ddded2');
18 changes: 9 additions & 9 deletions postgresql/data/initial_data_timetable1.sql
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
-- Insert test data into the faculty table
INSERT INTO vsu_timetable.faculty (id, name)
INSERT INTO timetable_vsu.faculty (id, name)
VALUES ('bbc6312c-f25e-4db3-b2a0-3f5dc6717a8d', 'Faculty of Mathematics and Mechanics');

-- Insert test data into the department table
INSERT INTO vsu_timetable.department (id, name, id_faculty)
INSERT INTO timetable_vsu.department (id, name, id_faculty)
VALUES ('1f93ceb4-d931-4b66-a0e5-7323d6b60f3b', 'Department of Applied Mathematics', 'bbc6312c-f25e-4db3-b2a0-3f5dc6717a8d');

-- Insert test data into the teacher table
INSERT INTO vsu_timetable.teacher (id, fio, bio, id_department)
INSERT INTO timetable_vsu.teacher (id, fio, bio, id_department)
VALUES ('241416c7-9654-4814-b36b-7d39c1ddded2', 'John Doe', 'Professor of Mathematics', '1f93ceb4-d931-4b66-a0e5-7323d6b60f3b');

-- Insert test data into the group table
INSERT INTO vsu_timetable.group (id, name, type)
INSERT INTO timetable_vsu.group (id, name, type)
VALUES ('c1fb3eac-de6d-44ef-bf35-18bebe832e1d', 'MM-21', 'magistracy');

-- Insert test data into the group_stage table
INSERT INTO vsu_timetable.group_stage (id, begin, "end", course, id_group)
INSERT INTO timetable_vsu.group_stage (id, begin, "end", course, id_group)
VALUES ('4148147a-740b-48f9-aba1-47eb17432855', '2023-09-01 00:00:00', '2024-06-30 00:00:00', 1, 'c1fb3eac-de6d-44ef-bf35-18bebe832e1d');

-- Insert test data into the room table
INSERT INTO vsu_timetable.room (id, name)
INSERT INTO timetable_vsu.room (id, name)
VALUES ('f245127f-a730-4d13-a15d-7648deb1d4d2', '101');

-- Insert test data into the subject table
INSERT INTO vsu_timetable.subject (id, name)
INSERT INTO timetable_vsu.subject (id, name)
VALUES ('053222c5-315a-4301-abfe-586d2409fcd3', 'Mathematics');

-- Insert test data into the shedule table
INSERT INTO vsu_timetable.shedule (id, id_teacher, id_subject, id_group_stage)
INSERT INTO timetable_vsu.shedule (id, id_teacher, id_subject, id_group_stage)
VALUES ('ab5f0559-d2ee-4030-919e-5962f1ff2235', '241416c7-9654-4814-b36b-7d39c1ddded2', '053222c5-315a-4301-abfe-586d2409fcd3', '4148147a-740b-48f9-aba1-47eb17432855');

-- Insert test data into the lesson table
INSERT INTO vsu_timetable.lesson (id, begin, "end", number_lesson, type_lesson, type_week, subgroup, day, id_room, id_shedule)
INSERT INTO timetable_vsu.lesson (id, begin, "end", number_lesson, type_lesson, type_week, subgroup, day, id_room, id_shedule)
VALUES ('3d04fc36-ab71-42db-9e38-efd792afa7ba', '2023-04-01 08:30:00', '2023-05-01 10:05:00', 1, 'lection', 'all', 'all', 'monday',
'f245127f-a730-4d13-a15d-7648deb1d4d2',
'ab5f0559-d2ee-4030-919e-5962f1ff2235');
18 changes: 9 additions & 9 deletions postgresql/data/initial_data_timetable2.sql
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
-- Insert test data into the faculty table
INSERT INTO vsu_timetable.faculty (id, name)
INSERT INTO timetable_vsu.faculty (id, name)
VALUES ('af8f26b8-afc7-483d-b6cc-ffaec29d4bc7', 'ПММ');

-- Insert test data into the department table
INSERT INTO vsu_timetable.department (id, name, id_faculty)
INSERT INTO timetable_vsu.department (id, name, id_faculty)
VALUES ('3ec37598-6c49-4a02-8134-d9dbffafa8c4', 'МОЭВМ', 'af8f26b8-afc7-483d-b6cc-ffaec29d4bc7');

-- Insert test data into the teacher table
INSERT INTO vsu_timetable.teacher (id, fio, bio, id_department)
INSERT INTO timetable_vsu.teacher (id, fio, bio, id_department)
VALUES ('dc5bad6f-fcf6-4869-b0e5-5c36aed85cc1', 'УСКОВА О.Ф.', 'ЛУЧШИЙ ПРЕПОД МИРА', '3ec37598-6c49-4a02-8134-d9dbffafa8c4');

-- Insert test data into the group table
INSERT INTO vsu_timetable.group (id, name, type)
INSERT INTO timetable_vsu.group (id, name, type)
VALUES ('c8a34f05-f081-4d78-b971-30d562fd9f1c', '62', 'undergraduate');

-- Insert test data into the group_stage table
INSERT INTO vsu_timetable.group_stage (id, begin, "end", course, id_group)
INSERT INTO timetable_vsu.group_stage (id, begin, "end", course, id_group)
VALUES ('4f9c8f36-c007-4d1a-9255-4a4ce8d45a96', '2023-09-01 00:00:00', '2024-06-30 00:00:00', 1, 'c8a34f05-f081-4d78-b971-30d562fd9f1c');

-- Insert test data into the room table
INSERT INTO vsu_timetable.room (id, name)
INSERT INTO timetable_vsu.room (id, name)
VALUES ('b5a90d34-307f-4ab1-9caf-8b6749189de8', '101');

-- Insert test data into the subject table
INSERT INTO vsu_timetable.subject (id, name)
INSERT INTO timetable_vsu.subject (id, name)
VALUES ('6990a617-405e-492a-990f-621ab0411623', 'Mathematics');

-- Insert test data into the shedule table
INSERT INTO vsu_timetable.shedule (id, id_teacher, id_subject, id_group_stage)
INSERT INTO timetable_vsu.shedule (id, id_teacher, id_subject, id_group_stage)
VALUES ('75021a69-9ceb-4eec-8151-34f93c0af429', 'dc5bad6f-fcf6-4869-b0e5-5c36aed85cc1', '6990a617-405e-492a-990f-621ab0411623', '4f9c8f36-c007-4d1a-9255-4a4ce8d45a96');

-- Insert test data into the lesson table
INSERT INTO vsu_timetable.lesson (id, begin, "end", number_lesson, type_lesson, type_week, subgroup, day, id_room, id_shedule)
INSERT INTO timetable_vsu.lesson (id, begin, "end", number_lesson, type_lesson, type_week, subgroup, day, id_room, id_shedule)
VALUES ('6e3092e3-ac10-47a8-b52b-a15682ecc40c', '2021-09-01 08:30:00', '2021-10-01 10:05:00', 1, 'practice', 'even', 'first', 'monday',
'b5a90d34-307f-4ab1-9caf-8b6749189de8',
'75021a69-9ceb-4eec-8151-34f93c0af429');
38 changes: 19 additions & 19 deletions postgresql/data/timetable_random.sql
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
-- Insert test data into the user table
INSERT INTO vsu_timetable.user (login, password)
INSERT INTO timetable_vsu.user (login, password)
VALUES ('user1', 'password1');

-- Insert test data into the token table
INSERT INTO vsu_timetable.token (expire_time, id_user)
VALUES ('2023-04-18 12:00:00', (SELECT id FROM vsu_timetable.user ORDER BY random() LIMIT 1));
INSERT INTO timetable_vsu.token (expire_time, id_user)
VALUES ('2023-04-18 12:00:00', (SELECT id FROM timetable_vsu.user ORDER BY random() LIMIT 1));

-- Insert test data into the admin table
INSERT INTO vsu_timetable.admin (id_user)
VALUES ((SELECT id FROM vsu_timetable.user ORDER BY random() LIMIT 1));
INSERT INTO timetable_vsu.admin (id_user)
VALUES ((SELECT id FROM timetable_vsu.user ORDER BY random() LIMIT 1));

-- Insert test data into the faculty table
INSERT INTO vsu_timetable.faculty (name)
INSERT INTO timetable_vsu.faculty (name)
VALUES ('Faculty of Mathematics and Mechanics');

-- Insert test data into the department table
INSERT INTO vsu_timetable.department (name, id_faculty)
VALUES ('Department of Applied Mathematics', (SELECT id FROM vsu_timetable.faculty ORDER BY random() LIMIT 1));
INSERT INTO timetable_vsu.department (name, id_faculty)
VALUES ('Department of Applied Mathematics', (SELECT id FROM timetable_vsu.faculty ORDER BY random() LIMIT 1));

-- Insert test data into the teacher table
INSERT INTO vsu_timetable.teacher (fio, bio, id_department)
VALUES ('John Doe', 'Professor of Mathematics', (SELECT id FROM vsu_timetable.department ORDER BY random() LIMIT 1));
INSERT INTO timetable_vsu.teacher (fio, bio, id_department)
VALUES ('John Doe', 'Professor of Mathematics', (SELECT id FROM timetable_vsu.department ORDER BY random() LIMIT 1));

-- Insert test data into the group table
INSERT INTO vsu_timetable."group" (name, type)
INSERT INTO timetable_vsu."group" (name, type)
VALUES ('MM-21', 'magistracy');

-- Insert test data into the group_stage table
INSERT INTO vsu_timetable.group_stage (begin, "end", course, id_group)
VALUES ('2023-09-01 00:00:00', '2024-06-30 00:00:00', 1, (SELECT id FROM vsu_timetable."group" ORDER BY random() LIMIT 1));
INSERT INTO timetable_vsu.group_stage (begin, "end", course, id_group)
VALUES ('2023-09-01 00:00:00', '2024-06-30 00:00:00', 1, (SELECT id FROM timetable_vsu."group" ORDER BY random() LIMIT 1));

-- Insert test data into the room table
INSERT INTO vsu_timetable.room (name)
INSERT INTO timetable_vsu.room (name)
VALUES ('Room 101');

-- Insert test data into the subject table
INSERT INTO vsu_timetable.subject (name)
INSERT INTO timetable_vsu.subject (name)
VALUES ('Mathematics');

-- Insert test data into the shedule table
INSERT INTO vsu_timetable.shedule (id_teacher, id_subject, id_group_stage)
VALUES ((SELECT id FROM vsu_timetable.teacher ORDER BY random() LIMIT 1), (SELECT id FROM vsu_timetable.subject ORDER BY random() LIMIT 1), (SELECT id FROM vsu_timetable.group_stage ORDER BY random() LIMIT 1));
INSERT INTO timetable_vsu.shedule (id_teacher, id_subject, id_group_stage)
VALUES ((SELECT id FROM timetable_vsu.teacher ORDER BY random() LIMIT 1), (SELECT id FROM timetable_vsu.subject ORDER BY random() LIMIT 1), (SELECT id FROM timetable_vsu.group_stage ORDER BY random() LIMIT 1));

-- Insert test data into the lesson table
INSERT INTO vsu_timetable.lesson (begin, "end", number_lesson, type_lesson, type_week, subgroup, day, id_room, id_shedule)
VALUES ('2023-09-01 08:30:00', '2023-09-01 10:05:00', 1, 'lection', 'all', 'all', 'monday', (SELECT id FROM vsu_timetable.room ORDER BY random() LIMIT 1), (SELECT id FROM vsu_timetable.shedule ORDER BY random() LIMIT 1));
INSERT INTO timetable_vsu.lesson (begin, "end", number_lesson, type_lesson, type_week, subgroup, day, id_room, id_shedule)
VALUES ('2023-09-01 08:30:00', '2023-09-01 10:05:00', 1, 'lection', 'all', 'all', 'monday', (SELECT id FROM timetable_vsu.room ORDER BY random() LIMIT 1), (SELECT id FROM timetable_vsu.shedule ORDER BY random() LIMIT 1));
Loading

0 comments on commit e96adfd

Please sign in to comment.