forked from huggle/huggle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStats.vb
99 lines (73 loc) · 3.42 KB
/
Stats.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'This is a source code or part of Huggle project
'Copyright (C) 2011 Huggle team
'This program is free software: you can redistribute it and/or modify
'it under the terms of the GNU General Public License as published by
'the Free Software Foundation, either version 3 of the License, or
'(at your option) any later version.
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License for more details.
NotInheritable Class Stats
'Static class keeping track of various statistics
Public Shared Groups As New Dictionary(Of String, Group)
Public Class Group
Public Shared ItemNames As String() = {"edits", "assisted", "huggle", "reverts", "warnings", "reports", _
"tags", "notifications", "blocks", "deletes", "protections"}
Public Items As New Dictionary(Of String, Integer)
Public Sub New()
For Each Item As String In ItemNames
Items.Add(Item, 0)
Next Item
End Sub
Default Public Property Item(ByVal Name As String) As Integer
Get
Return Items(Name)
End Get
Set(ByVal value As Integer)
Items(Name) = value
End Set
End Property
End Class
Shared Sub New()
For Each Item As String In New String() {"allusers", "me", "ignored", "anon", "bots", "other"}
Groups.Add(Item, New Group)
Next Item
End Sub
Public Shared Sub Update(ByVal Item As Edit)
'Update statistics and edit counts
UpdateGroup("allusers", Item)
If Item.User IsNot Nothing Then _
If Item.User.IsMe Then UpdateGroup("me", Item) _
Else If Item.User.Anonymous Then UpdateGroup("anon", Item) _
Else If Item.Bot Then UpdateGroup("bots", Item) _
Else If Item.User.Ignored Then UpdateGroup("ignored", Item) _
Else UpdateGroup("other", Item)
End Sub
Public Shared Sub UpdateGroup(ByVal Name As String, ByVal Item As Edit)
Dim Group As Group = Groups(Name)
Group("edits") += 1
If Item.Type = EditType.Notification Then Group("notifications") += 1
If Item.Type = EditType.Report Then Group("reports") += 1
If Item.Type = EditType.Revert Then Group("reverts") += 1
If Item.Type = EditType.Tag Then Group("tags") += 1
If Item.Type = EditType.Warning Then Group("warnings") += 1
If Item.Assisted Then Group("assisted") += 1
If Item.IsHuggleEdit Then Group("huggle") += 1
End Sub
Public Shared Sub Update(ByVal Item As Block)
Groups("allusers")("blocks") += 1
If Item.Admin IsNot Nothing Then _
If Item.Admin.IsMe Then Groups("me")("blocks") += 1 Else Groups("ignored")("blocks") += 1
End Sub
Public Shared Sub Update(ByVal Item As Delete)
Groups("allusers")("deletes") += 1
If Item.Admin IsNot Nothing Then _
If Item.Admin.IsMe Then Groups("me")("deletes") += 1 Else Groups("ignored")("deletes") += 1
End Sub
Public Shared Sub Update(ByVal Item As Protection)
Groups("allusers")("protections") += 1
If Item.Admin IsNot Nothing Then _
If Item.Admin.IsMe Then Groups("me")("protections") += 1 Else Groups("ignored")("protections") += 1
End Sub
End Class