This commit is contained in:
2020-12-19 21:16:44 +01:00
parent 48fa997811
commit 7478e85bae
11 changed files with 149 additions and 44 deletions

View File

@@ -1,31 +1,44 @@
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import {getTotalStats, getWeeklyStats, getMonthlyStats, getOtherStats} from 'App/Helpers/StatsHelper'
import DockerBuild from "App/Models/DockerBuild";
import DockerCommand from "App/Models/DockerCommand";
export default class StatsController {
public async get ({response}: HttpContextContract) {
return response.status(200).send({
daily: this.getDailyStats(),
weekly: this.getWeeklyStats(),
monthly: this.getMontlyStats()
weekly: getWeeklyStats(),
monthly: getMonthlyStats(),
total: getTotalStats(),
other : getOtherStats()
})
}
getDailyStats() {
return {
development_hours: 0
public async incrementBuild () {
const date = new Date()
const last_entry = await DockerBuild.findBy('created_at', date)
if (last_entry) {
last_entry.builds = last_entry.builds ++
await last_entry.save()
} else {
await DockerBuild.create({
builds: BigInt(1)
})
}
}
getWeeklyStats() {
return {
development_hours: 0
}
}
public async incrementCommand () {
const date = new Date()
const last_entry = await DockerCommand.findBy('created_at', date)
getMontlyStats() {
return {
development_hours: 0
if (last_entry) {
last_entry.commands = last_entry.commands ++
await last_entry.save()
} else {
await DockerCommand.create({
commands: BigInt(1)
})
}
}