mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 20:19:26 +01:00
Remove Discord Activity route
This commit is contained in:
@@ -1,10 +1,67 @@
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import {
|
||||
fetchDailyStatistics,
|
||||
fetchMonthlyStatistics,
|
||||
fetchStatistics,
|
||||
fetchWeeklyStatistics
|
||||
} from "App/Tasks/DevelopmentHoursTask";
|
||||
import CommandsRun from "App/Models/CommandsRun";
|
||||
import {DateTime} from "luxon";
|
||||
import BuildsRun from "App/Models/BuildsRun";
|
||||
|
||||
export default class StatsController {
|
||||
|
||||
public async index ({ response }: HttpContextContract) {
|
||||
const daily = await fetchDailyStatistics()
|
||||
const weekly = await fetchWeeklyStatistics()
|
||||
const monthly = await fetchMonthlyStatistics()
|
||||
const total = await fetchStatistics()
|
||||
|
||||
return response.status(200).send({
|
||||
message: 'Stats is under maintenance! Come back later.'
|
||||
daily,
|
||||
weekly,
|
||||
monthly,
|
||||
total
|
||||
})
|
||||
}
|
||||
|
||||
public async incrementCommandCount({ response }: HttpContextContract) {
|
||||
const current_date = DateTime.fromJSDate(new Date(new Date().setUTCMinutes(0, 0, 0)))
|
||||
const current_commands = await CommandsRun.firstOrCreate(
|
||||
{
|
||||
date: current_date
|
||||
},
|
||||
{
|
||||
date: current_date,
|
||||
commands: 0
|
||||
}
|
||||
)
|
||||
|
||||
current_commands.commands++
|
||||
await current_commands.save()
|
||||
|
||||
return response.status(200).send({
|
||||
message: 'Commands Count successfully incremented !'
|
||||
})
|
||||
}
|
||||
|
||||
public async incrementBuildCount({ response }: HttpContextContract) {
|
||||
const current_date = DateTime.fromJSDate(new Date(new Date().setUTCMinutes(0, 0, 0)))
|
||||
const current_builds = await BuildsRun.firstOrCreate(
|
||||
{
|
||||
date: current_date
|
||||
},
|
||||
{
|
||||
date: current_date,
|
||||
builds: 0
|
||||
}
|
||||
)
|
||||
|
||||
current_builds.builds++
|
||||
await current_builds.save()
|
||||
|
||||
return response.status(200).send({
|
||||
message: 'Builds Count successfully incremented !'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user