Remove Discord Activity route

This commit is contained in:
2021-10-08 15:02:22 +02:00
parent 5074e37807
commit c8a09d9ab6
3 changed files with 72 additions and 4 deletions

View File

@@ -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 !'
})
}