fix: database location
Founded a major mistake: db overwrites during install. Now all scripts save db in special folder and don't overwrite it.
This commit is contained in:
27
old/data/groups.json
Normal file
27
old/data/groups.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"ib4k": {
|
||||
"parseId": 138,
|
||||
"name": "ИБ-4к",
|
||||
"course": 4
|
||||
},
|
||||
"ib5": {
|
||||
"parseId": 144,
|
||||
"name": "ИБ-5",
|
||||
"course": 3
|
||||
},
|
||||
"ib6": {
|
||||
"parseId": 145,
|
||||
"name": "ИБ-6",
|
||||
"course": 3
|
||||
},
|
||||
"ib7k": {
|
||||
"parseId": 172,
|
||||
"name": "ИБ-7к",
|
||||
"course": 3
|
||||
},
|
||||
"ib3": {
|
||||
"parseId": 123,
|
||||
"name": "ИБ-3",
|
||||
"course": 4
|
||||
}
|
||||
}
|
||||
18
old/data/groups.ts
Normal file
18
old/data/groups.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// Загружаем группы из JSON файла только на сервере
|
||||
// На клиенте будет пустой объект, группы должны передаваться через props
|
||||
let groups: { [group: string]: [number, string] } = {}
|
||||
|
||||
// Используем условный require только на сервере для избежания включения fs в клиентскую сборку
|
||||
if (typeof window === 'undefined') {
|
||||
// Серверная сторона
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const groupsLoader = require('./groups-loader')
|
||||
groups = groupsLoader.loadGroups()
|
||||
} catch (error) {
|
||||
console.error('Error loading groups:', error)
|
||||
groups = {}
|
||||
}
|
||||
}
|
||||
|
||||
export { groups }
|
||||
Reference in New Issue
Block a user