Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Castopod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johannes Zellner
Castopod
Commits
0188b673
Commit
0188b673
authored
2 years ago
by
Benjamin Bellamy
Committed by
Yassine Doghri
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(analytics-gdpr): update cached personal data to expire at midnight
parent
df8506bb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/Analytics/Helpers/analytics_helper.php
+6
-14
6 additions, 14 deletions
modules/Analytics/Helpers/analytics_helper.php
with
6 additions
and
14 deletions
modules/Analytics/Helpers/analytics_helper.php
+
6
−
14
View file @
0188b673
...
@@ -290,17 +290,11 @@ if (! function_exists('podcast_hit')) {
...
@@ -290,17 +290,11 @@ if (! function_exists('podcast_hit')) {
'Y-m-d'
'Y-m-d'
)
.
'_'
.
$_SERVER
[
'REMOTE_ADDR'
]
.
'_'
.
$_SERVER
[
'HTTP_USER_AGENT'
]
.
'_'
.
$episodeId
)
.
'_'
.
$_SERVER
[
'REMOTE_ADDR'
]
.
'_'
.
$_SERVER
[
'HTTP_USER_AGENT'
]
.
'_'
.
$episodeId
);
);
// Was this episode downloaded in the past 24h:
// The cache expires at midnight:
$secondsToMidnight
=
strtotime
(
'tomorrow'
)
-
time
();
$downloadedBytes
=
cache
(
$episodeListenerHashId
);
$downloadedBytes
=
cache
(
$episodeListenerHashId
);
// Rolling window is 24 hours (86400 seconds):
if
(
$downloadedBytes
===
null
)
{
$rollingTTL
=
86400
;
// If it was never downloaded that means that zero bytes were downloaded:
if
(
$downloadedBytes
)
{
// In case it was already downloaded, TTL should be adjusted (rolling window is 24h since 1st download):
$rollingTTL
=
cache
()
->
getMetadata
(
$episodeListenerHashId
)[
'expire'
]
-
time
();
}
else
{
// If it was never downloaded that means that zero byte were downloaded:
$downloadedBytes
=
0
;
$downloadedBytes
=
0
;
}
}
...
@@ -326,7 +320,7 @@ if (! function_exists('podcast_hit')) {
...
@@ -326,7 +320,7 @@ if (! function_exists('podcast_hit')) {
// We save the number of downloaded bytes for this user and this episode:
// We save the number of downloaded bytes for this user and this episode:
cache
()
cache
()
->
save
(
$episodeListenerHashId
,
$downloadedBytes
,
$
rollingTTL
);
->
save
(
$episodeListenerHashId
,
$downloadedBytes
,
$
secondsToMidnight
);
// If more that 1mn was downloaded, that's a hit, we send that to the database:
// If more that 1mn was downloaded, that's a hit, we send that to the database:
if
(
$downloadedBytes
>=
$bytesThreshold
)
{
if
(
$downloadedBytes
>=
$bytesThreshold
)
{
...
@@ -354,11 +348,9 @@ if (! function_exists('podcast_hit')) {
...
@@ -354,11 +348,9 @@ if (! function_exists('podcast_hit')) {
$downloadsByUser
=
1
;
$downloadsByUser
=
1
;
}
}
// Listener count is calculated from 00h00 to 23h59:
$midnightTTL
=
strtotime
(
'tomorrow'
)
-
time
();
// We save the download count for this user until midnight:
// We save the download count for this user until midnight:
cache
()
cache
()
->
save
(
$podcastListenerHashId
,
$downloadsByUser
,
$
m
idnight
TTL
);
->
save
(
$podcastListenerHashId
,
$downloadsByUser
,
$
secondsToM
idnight
);
$db
->
query
(
$db
->
query
(
"CALL
{
$procedureName
}
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"
,
"CALL
{
$procedureName
}
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment