mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-28 18:40:27 +01:00
💻 | Working on API
This commit is contained in:
15
app/Helpers/GetWakatimeActivity.ts
Normal file
15
app/Helpers/GetWakatimeActivity.ts
Normal 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
|
||||
}
|
||||
@@ -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}
|
||||
Reference in New Issue
Block a user