feat: add health
This commit is contained in:
parent
b2d23dd6d8
commit
12241d52b9
3 changed files with 26 additions and 10 deletions
|
|
@ -11,7 +11,10 @@ export default class UserController {
|
|||
async me({ auth }: HttpContext) {
|
||||
return {
|
||||
success: true,
|
||||
data: auth.user,
|
||||
data: {
|
||||
...auth.user?.serialize(),
|
||||
email: auth.user!.email || '',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,19 @@ import Examiner from '#models/examiner'
|
|||
import Room from '#models/room'
|
||||
import Subject from '#models/subject'
|
||||
import User from '#models/user'
|
||||
import redis from '@adonisjs/redis/services/main'
|
||||
|
||||
export class ColleService {
|
||||
async getHealthyUntil(className: string) {
|
||||
const healtyUntil = await redis.get(`healthy_until_${className}`)
|
||||
return new Date(healtyUntil || '')
|
||||
}
|
||||
|
||||
async getLastSync(className: string) {
|
||||
const lastSync = await redis.get(`last_sync_${className}`)
|
||||
return new Date(lastSync || '')
|
||||
}
|
||||
|
||||
async getStudent(studentName: string, className: string) {
|
||||
// Find or create a student by name
|
||||
const { firstName, lastName } = this.splitNames(studentName)
|
||||
|
|
@ -90,6 +101,8 @@ export class ColleService {
|
|||
classColles,
|
||||
studentColles,
|
||||
favoriteColles,
|
||||
healthyUntil: await this.getHealthyUntil(student.className),
|
||||
lastSync: await this.getLastSync(student.className),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,16 +37,16 @@ const SubjectsController = () => import('#controllers/subjects_controller')
|
|||
router.get('/subjects', [SubjectsController, 'index']).use(middleware.auth())
|
||||
|
||||
// TEST ROUTE
|
||||
import redis from '@adonisjs/redis/services/main'
|
||||
// import redis from '@adonisjs/redis/services/main'
|
||||
|
||||
router.get('/', async () => {
|
||||
await redis.publish("jobs_queue", JSON.stringify({
|
||||
type: 1,
|
||||
date: "20/09/2019",
|
||||
class_name: "MPSI 2",
|
||||
}))
|
||||
return { message: 'Hello, world!' }
|
||||
})
|
||||
// router.get('/', async () => {
|
||||
// await redis.publish("jobs_queue", JSON.stringify({
|
||||
// type: 1,
|
||||
// date: "20/09/2019",
|
||||
// class_name: "MPSI 2",
|
||||
// }))
|
||||
// return { message: 'Hello, world!' }
|
||||
// })
|
||||
// END TEST ROUTE
|
||||
|
||||
const CollesController = () => import('#controllers/colles_controller')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue