2.2 KiB
2.2 KiB
status, type, tags, created, updated, source, aliases
| status | type | tags | created | updated | source | aliases | ||||
|---|---|---|---|---|---|---|---|---|---|---|
| seed | guide |
|
2026-05-25 | 2026-05-25 | Работа с API для проекта Attendance Mephi |
|
API импорт в Rails через runner
Памятка по ручному запуску импортов в Ruby On Rails - MOC-проекте Attendance Mephi для НИР.
Контекст
Импорт запускается через bin/rails runner:
/home/ada/.local/bin/mise exec ruby -- bin/rails runner '...'
Актуальный семестр берется из Term.actual. Для старта 2026-02-07 код семестра: 20252.
Credentials
api:
home_mephi:
host:
code:
token:
students_mephi:
host:
username:
password:
См. также: Rails credentials edit не открывает редактор.
Endpoints
GET {home_mephi.host}/study_groups.json?term_code=20252&code=...&token=...
GET {home_mephi.host}/tutors.json?term_code=20252&code=...&token=...
GET {students_mephi.host}/get_list_by_group_name?group=...&term=20252
GET {home_mephi.host}/tutors/{staff_id}/schedules.json?term_code=20252&date=YYYY-MM-DD&code=...&token=...
students_mephi использует Basic Auth: username/password.
Ручная загрузка
/home/ada/.local/bin/mise exec ruby -- bin/rails runner 'ImportGroupsService.execute'
/home/ada/.local/bin/mise exec ruby -- bin/rails runner 'ImportTutorsService.execute'
/home/ada/.local/bin/mise exec ruby -- bin/rails runner 'ImportStudentsService.execute'
/home/ada/.local/bin/mise exec ruby -- bin/rails runner 'term = Term.actual; ImportDisciplineService.execute(nil, term)'
Расписание на сегодня:
/home/ada/.local/bin/mise exec ruby -- bin/rails runner 'term = Term.actual; ImportScheduleService.execute(Date.today, term)'
Расписание за весь семестр до сегодня:
/home/ada/.local/bin/mise exec ruby -- bin/rails runner 'term = Term.actual; finish = [term.get_finish_date, Date.today].min; (term.start_date..finish).each { |date| ImportScheduleService.execute(date, term) unless date.wday == 0 }'