adding sinceDate
This commit is contained in:
parent
3ec4b4a790
commit
5598b2f615
2 changed files with 41 additions and 13 deletions
|
@ -21,11 +21,13 @@
|
||||||
<div id="weeklyLineInfo"></div>
|
<div id="weeklyLineInfo"></div>
|
||||||
<div class="monthlyInfo">
|
<div class="monthlyInfo">
|
||||||
<h3>Last 30 Days</h3>
|
<h3>Last 30 Days</h3>
|
||||||
|
<p id="since"></p>
|
||||||
<p id="monthlyPregreet"></p>
|
<p id="monthlyPregreet"></p>
|
||||||
<p id="monthlyNoqueue"></p>
|
<p id="monthlyNoqueue"></p>
|
||||||
<p id="monthlyQuarantine"></p>
|
<p id="monthlyQuarantine"></p>
|
||||||
<p id="monthlySpam"></p>
|
<p style="font-weight:bold;" id="monthlySpam"></p>
|
||||||
<p id="monthlyHam"></p>
|
<p style="font-weight:bold;" id="monthlyHam"></p>
|
||||||
|
<p id="ratio"></p>
|
||||||
</div>
|
</div>
|
||||||
<script src="Chart.js"></script>
|
<script src="Chart.js"></script>
|
||||||
<script src="data.js"></script>
|
<script src="data.js"></script>
|
||||||
|
@ -50,6 +52,8 @@
|
||||||
document.getElementById('monthlyQuarantine').innerHTML = "Quarantined: " + data['monthlyQuarantine'];
|
document.getElementById('monthlyQuarantine').innerHTML = "Quarantined: " + data['monthlyQuarantine'];
|
||||||
document.getElementById('monthlySpam').innerHTML = "Total Spam: " + data['monthlySpam'];
|
document.getElementById('monthlySpam').innerHTML = "Total Spam: " + data['monthlySpam'];
|
||||||
document.getElementById('monthlyHam').innerHTML = "Total Ham: " + data['monthlyHam'];
|
document.getElementById('monthlyHam').innerHTML = "Total Ham: " + data['monthlyHam'];
|
||||||
|
document.getElementById('since').innerHTML = "Starting on " + data['since'];
|
||||||
|
document.getElementById('ratio').innerHTML = "Ratio: 1:" + (data['monthlySpam'] / data['monthlyHam']).toFixed(0);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -85,16 +85,26 @@ func load (dataset DataMap, date string, str string, num int) ( DataMap ) {
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// Begin Arguments
|
// Begin Arguments
|
||||||
sourceFile := flag.String("source", "/var/log/spam.log", "The path to the spam log")
|
sourceFile := flag.String("source", "/var/log/spam.log",
|
||||||
outfile := flag.String("out", "data.js", "The path to the file you want to output.")
|
"The path to the spam log")
|
||||||
hamColor := flag.String("hamcolor","rgba(80,220,80,1)","The color of the ham graph.")
|
outfile := flag.String("out", "data.js",
|
||||||
hamFill := flag.String("hamfill","rgba(80,220,80,0.2)","The fill color of the ham graph.")
|
"The path to the file you want to output.")
|
||||||
quarantineColor := flag.String("quarantinecolor","rgba(220,80,80,1)","The line color of the quarantine graph.")
|
hamColor := flag.String("hamcolor","rgba(80,220,80,1)",
|
||||||
quarantineFill := flag.String("quarantinefill","rgba(220,80,80,0.2)","The fill color of the quarantine graph.")
|
"The color of the ham graph.")
|
||||||
noqueueColor := flag.String("noqueuecolor","rgba(220,150,80,1)","The line color of the noqueue graph.")
|
hamFill := flag.String("hamfill","rgba(80,220,80,0.2)",
|
||||||
noqueueFill := flag.String("noqueuefill","rgba(220,150,80,0.2)","The fill color of the noqueue graph.")
|
"The fill color of the ham graph.")
|
||||||
pregreetColor := flag.String("pregreetcolor","rgba(220,200,80,1)","The line color of the pregreet graph.")
|
quarantineColor := flag.String("quarantinecolor","rgba(220,80,80,1)",
|
||||||
pregreetFill := flag.String("pregreetfill","rgba(220,200,80,0.2)","The fill color of the pregreet graph.")
|
"The line color of the quarantine graph.")
|
||||||
|
quarantineFill := flag.String("quarantinefill","rgba(220,80,80,0.2)",
|
||||||
|
"The fill color of the quarantine graph.")
|
||||||
|
noqueueColor := flag.String("noqueuecolor","rgba(220,150,80,1)",
|
||||||
|
"The line color of the noqueue graph.")
|
||||||
|
noqueueFill := flag.String("noqueuefill","rgba(220,150,80,0.2)",
|
||||||
|
"The fill color of the noqueue graph.")
|
||||||
|
pregreetColor := flag.String("pregreetcolor","rgba(220,200,80,1)",
|
||||||
|
"The line color of the pregreet graph.")
|
||||||
|
pregreetFill := flag.String("pregreetfill","rgba(220,200,80,0.2)",
|
||||||
|
"The fill color of the pregreet graph.")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
// End Arguments
|
// End Arguments
|
||||||
|
|
||||||
|
@ -107,6 +117,7 @@ func main() {
|
||||||
// Start semi-constants
|
// Start semi-constants
|
||||||
aWeekAgo := time.Now().AddDate(0,0,-8)
|
aWeekAgo := time.Now().AddDate(0,0,-8)
|
||||||
aMonthAgo := time.Now().AddDate(0,0,-31)
|
aMonthAgo := time.Now().AddDate(0,0,-31)
|
||||||
|
dateFormat := "2006-01-02"
|
||||||
// End semi-constants
|
// End semi-constants
|
||||||
|
|
||||||
// Start temporary maps
|
// Start temporary maps
|
||||||
|
@ -121,7 +132,6 @@ func main() {
|
||||||
return
|
return
|
||||||
} // if err != nil
|
} // if err != nil
|
||||||
|
|
||||||
dateFormat := "2006-01-02"
|
|
||||||
date, _ := time.Parse(dateFormat, val[0])
|
date, _ := time.Parse(dateFormat, val[0])
|
||||||
|
|
||||||
if date.After(aWeekAgo) {
|
if date.After(aWeekAgo) {
|
||||||
|
@ -158,6 +168,16 @@ func main() {
|
||||||
|
|
||||||
monthlySpam := monthlyPregreet + monthlyNoqueue + monthlyQuarantine
|
monthlySpam := monthlyPregreet + monthlyNoqueue + monthlyQuarantine
|
||||||
|
|
||||||
|
sinceDate := time.Now().AddDate(10,0,0)
|
||||||
|
for k := range monthly {
|
||||||
|
date, _ := time.Parse(dateFormat, k)
|
||||||
|
if date.Before(sinceDate) {
|
||||||
|
sinceDate = date
|
||||||
|
} // if date.Before(since)
|
||||||
|
} // for k in monthly
|
||||||
|
var since string
|
||||||
|
since = sinceDate.Format(dateFormat)
|
||||||
|
|
||||||
var labels []string
|
var labels []string
|
||||||
for k := range weekly {
|
for k := range weekly {
|
||||||
labels = append(labels, k)
|
labels = append(labels, k)
|
||||||
|
@ -304,6 +324,10 @@ func main() {
|
||||||
|
|
||||||
buffer.WriteString("\tmonthlyHam: \"")
|
buffer.WriteString("\tmonthlyHam: \"")
|
||||||
buffer.WriteString(strconv.Itoa(monthlyHam))
|
buffer.WriteString(strconv.Itoa(monthlyHam))
|
||||||
|
buffer.WriteString("\",\n")
|
||||||
|
|
||||||
|
buffer.WriteString("\tsince: \"")
|
||||||
|
buffer.WriteString(since)
|
||||||
buffer.WriteString("\"\n")
|
buffer.WriteString("\"\n")
|
||||||
|
|
||||||
buffer.WriteString("};\n\n")
|
buffer.WriteString("};\n\n")
|
||||||
|
|
Loading…
Reference in a new issue