FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CovidVaultAPI/model/Statistics.php at master · SimpleProgrammingAU/CovidVaultAPI · GitHub
This repository was archived by the owner on Jun 8, 2023. It is now read-only.
SimpleProgrammingAU
/
CovidVaultAPI
Public archive
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
3
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
CovidVaultAPI
/
model
/
Statistics.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
114 lines (106 loc) · 2.32 KB
Breadcrumbs
CovidVaultAPI
/
model
/
Statistics.php
Copy path
File metadata and controls
114 lines (106 loc) · 2.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
require_once
'
../model/Location.php
'
;
class
Statistics
{
const
DAY
=
10001
;
const
HOUR
=
10002
;
/**
* @var Location
*/
private
$
_location
;
/**
* @var int[]
*/
private
$
_visitors_by_day
;
/**
* @var int[]
*/
private
$
_visitors_by_hour
;
/**
* @var mixed[]
*/
private
$
_api_calls_by_month
;
/**
* @var float
*/
private
$
_p_return_visitors
;
/**
* @var int
*/
private
$
_n_visitors_today
;
public
function
__construct
()
{
$
this
->
_location
=
new
Location
();
$
this
->
_visitors_by_day
=
array_fill
(
0
,
7
,
0
);
$
this
->
_visitors_by_hour
=
array_fill
(
0
,
24
,
0
);
$
this
->
_api_calls_by_month
= [];
$
this
->
_n_visitors_today
=
0
;
$
this
->
_p_return_visitors
=
0
;
}
public
function
location
():
Location
{
return
$
this
->
_location
;
}
public
function
getTimeStats
(
int
$
type
):
array
{
switch
(
$
type
) {
case
self
::
DAY
:
return
$
this
->
_visitors_by_day
;
case
self
::
HOUR
:
return
$
this
->
_visitors_by_hour
;
}
throw
new
Error
(
"
Invalid time statistic entered.
"
);
}
public
function
getAPIStats
():
array
{
return
$
this
->
_api_calls_by_month
;
}
public
function
getReturnStats
():
float
{
return
$
this
->
_p_return_visitors
;
}
public
function
getTodayCount
():
int
{
return
$
this
->
_n_visitors_today
;
}
public
function
importDay
(
array
$
data
):
bool
{
foreach
(
$
data
as
$
value
) {
$
this
->
_visitors_by_day
[
$
value
[
"
id
"
]] =
intval
(
$
value
[
'
N
'
]) /
intval
(
$
value
[
'
F
'
]);
}
return
true
;
}
public
function
importHour
(
array
$
data
):
bool
{
foreach
(
$
data
as
$
value
) {
$
this
->
_visitors_by_hour
[
$
value
[
"
id
"
]] =
intval
(
$
value
[
'
N
'
]);
}
return
true
;
}
public
function
importAPIStats
(
array
$
data
):
bool
{
$
this
->
_api_calls_by_month
= [];
try
{
foreach
(
$
data
as
$
row
) {
$
this
->
_api_calls_by_month
[] = [
"
year
"
=>
intval
(
$
row
[
"
year
"
]),
"
month
"
=>
intval
(
$
row
[
"
month
"
]),
"
count
"
=>
intval
(
$
row
[
"
n
"
])
];
}
return
true
;
}
catch
(
Exception
$
e
) {
return
false
;
}
}
public
function
setReturn
(
float
$
return
):
bool
{
$
this
->
_p_return_visitors
=
round
(
$
return
*
100
,
0
);
return
true
;
}
public
function
setToday
(
int
$
today
):
bool
{
$
this
->
_n_visitors_today
=
intval
(
$
today
);
return
true
;
}
}
Back
|
FazBrowse Home
|
New Git URL