mirror of https://github.com/statping/statping
build bruh
parent
e8848c824b
commit
9636f058de
|
@ -159,6 +159,9 @@ func Openw(dialect string, args ...interface{}) (db Database, err error) {
|
|||
gorm.NowFunc = func() time.Time {
|
||||
return utils.Now()
|
||||
}
|
||||
if dialect == "sqlite" {
|
||||
dialect = "sqlite3"
|
||||
}
|
||||
gormdb, err := gorm.Open(dialect, args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -198,7 +198,7 @@ class Api {
|
|||
}
|
||||
|
||||
async logs() {
|
||||
return axios.get('api/logs').then(response => (response.data))
|
||||
return axios.get('api/logs').then(response => (response.data)) || []
|
||||
}
|
||||
|
||||
async logs_last() {
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import Api from "../../API";
|
||||
import MiniSparkLine from './MiniSparkLine';
|
||||
import ServiceSparkLine from './ServiceSparkLine';
|
||||
|
||||
|
@ -42,21 +41,6 @@
|
|||
this.chart = this.convertToChartData(this.func.chart);
|
||||
}
|
||||
},
|
||||
async latencyYesterday() {
|
||||
const todayTime = await Api.service_hits(this.service.id, this.toUnix(this.nowSubtract(86400)), this.toUnix(new Date()), this.group, false)
|
||||
const fetched = await Api.service_hits(this.service.id, this.start, this.end, this.group, false)
|
||||
|
||||
let todayAmount = this.addAmounts(todayTime)
|
||||
let yesterday = this.addAmounts(fetched)
|
||||
|
||||
},
|
||||
addAmounts(data) {
|
||||
let total = 0
|
||||
data.forEach((f) => {
|
||||
total += parseInt(f.amount)
|
||||
});
|
||||
return total
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
import ServiceFailures from './ServiceFailures';
|
||||
import ServiceSparkLine from "./ServiceSparkLine";
|
||||
import Api from "../../API";
|
||||
import StatsGen from "./StatsGen";
|
||||
|
||||
export default {
|
||||
name: 'ServiceInfo',
|
||||
|
@ -113,7 +112,6 @@
|
|||
ServiceFailures,
|
||||
FormIncident,
|
||||
FormMessage,
|
||||
StatsGen,
|
||||
ServiceSparkLine
|
||||
},
|
||||
props: {
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
<template>
|
||||
<div class="col-3 text-left">
|
||||
<span class="text-success font-5 font-weight-bold">{{value}}</span>
|
||||
<span class="font-2 d-block">{{title}}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Api from "../../API";
|
||||
|
||||
export default {
|
||||
name: 'StatsGen',
|
||||
props: {
|
||||
service: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
start: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
end: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
group: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
expression: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
in_value: {
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
value: "+17%"
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
if (this.in_value) {
|
||||
this.value = this.in_value
|
||||
}
|
||||
await this.latencyYesterday();
|
||||
},
|
||||
methods: {
|
||||
async latencyYesterday() {
|
||||
const todayTime = await Api.service_hits(this.service.id, this.toUnix(this.nowSubtract(86400)), this.toUnix(new Date()), this.group, false)
|
||||
const fetched = await Api.service_hits(this.service.id, this.start, this.end, this.group, false)
|
||||
|
||||
let todayAmount = this.addAmounts(todayTime)
|
||||
let yesterday = this.addAmounts(fetched)
|
||||
|
||||
},
|
||||
addAmounts(data) {
|
||||
let total = 0
|
||||
data.forEach((f) => {
|
||||
total += parseInt(f.amount)
|
||||
});
|
||||
return total
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped>
|
||||
</style>
|
|
@ -154,7 +154,6 @@ export default new Vuex.Store({
|
|||
const messages = await Api.messages()
|
||||
context.commit("setMessages", messages)
|
||||
context.commit("setHasPublicData", true)
|
||||
window.console.log('finished loading required data')
|
||||
},
|
||||
async loadAdmin(context) {
|
||||
const groups = await Api.groups()
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/statping/statping/types/checkins"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/null"
|
||||
"github.com/statping/statping/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -81,8 +82,8 @@ type Stats struct {
|
|||
// BeforeCreate for Service will set CreatedAt to UTC
|
||||
func (s *Service) BeforeCreate() (err error) {
|
||||
if s.CreatedAt.IsZero() {
|
||||
s.CreatedAt = time.Now().UTC()
|
||||
s.UpdatedAt = time.Now().UTC()
|
||||
s.CreatedAt = utils.Now()
|
||||
s.UpdatedAt = utils.Now()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue