💻 | Working on API

This commit is contained in:
2021-04-05 17:14:57 +02:00
parent 4483e9139e
commit 933109aceb
29 changed files with 201 additions and 463 deletions

View File

@@ -0,0 +1,15 @@
import axios from "axios";
import Env from "@ioc:Adonis/Core/Env";
export default function getActivity() {
let last_activity = ''
axios.get('https://wakatime.com/api/v1/users/current', {
headers: {
'Authorization': `Basic ${Env.get('WAKATIME_API_KEY')}`
}
})
.then((res) => {
last_activity = res.data.last_heartbeat_at
})
return last_activity
}

View File

@@ -1,45 +0,0 @@
import DockerCommand from "App/Models/DockerCommand";
import DockerBuild from "App/Models/DockerBuild";
async function getDailyStats() {
const commands = await DockerCommand.query().where('created_at', '>', new Date().getTime())
const builds = await DockerBuild.query().where('created_at', '>', new Date().getTime())
return {
docker_commands_run: commands.length,
docker_build_count: builds.length,
}
}
async function getWeeklyStats() {
const commands = await DockerCommand.query().where('created_at', '>', new Date().getTime() - 1000 * 60 * 60 * 24 * 7)
const builds = await DockerBuild.query().where('created_at', '>', new Date().getTime() - 1000 * 60 * 60 * 24 * 7)
return {
docker_commands_run: commands.length,
docker_build_count: builds.length,
}
}
async function getMonthlyStats() {
const commands = await DockerCommand.query().where('created_at', '>', new Date().getMonth() - 1)
const builds = await DockerBuild.query().where('created_at', '>', new Date().getMonth() - 1)
return {
docker_commands_run: commands.length,
docker_build_count: builds.length,
}
}
async function getTotalStats() {
const commands = await DockerCommand.query()
const builds = await DockerBuild.query()
return {
docker_commands_run: commands.length,
docker_build_count: builds.length
}
}
export {getMonthlyStats, getTotalStats, getWeeklyStats, getDailyStats}