Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PaymentServer
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Administrator
PaymentServer
Commits
00265d83
Commit
00265d83
authored
4 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Record first successful redemption of any voucher, counter pair
parent
f6cdb686
Branches
Branches containing commit
No related tags found
1 merge request
!70
Record first successful redemption of any voucher, counter pair
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/PaymentServer/Persistence.hs
+16
-0
16 additions, 0 deletions
src/PaymentServer/Persistence.hs
with
16 additions
and
0 deletions
src/PaymentServer/Persistence.hs
+
16
−
0
View file @
00265d83
...
...
@@ -37,6 +37,9 @@ import qualified Database.SQLite.Simple as Sqlite
import
Database.SQLite.Simple.FromRow
(
FromRow
(
fromRow
)
)
import
qualified
Prometheus
as
P
import
Data.Maybe
(
listToMaybe
)
...
...
@@ -259,6 +262,7 @@ redeemVoucherHelper isVoucherPaid lookupFingerprint lookupVoucherCounter markVou
return
$
Left
NotPaid
(
True
,
Nothing
)
->
do
markVoucherRedeemed
(
voucher
,
counter
)
fingerprint
P
.
incCounter
voucherRedeemed
return
$
Right
()
(
True
,
Just
fingerprint'
)
->
if
fingerprint
==
fingerprint'
then
...
...
@@ -267,6 +271,18 @@ redeemVoucherHelper isVoucherPaid lookupFingerprint lookupVoucherCounter markVou
return
$
Left
AlreadyRedeemed
metricName
::
Text
->
Text
metricName
name
=
mappend
"redemption."
name
voucherRedeemed
::
P
.
Counter
voucherRedeemed
=
P
.
unsafeRegister
$
P
.
counter
$
P
.
Info
(
metricName
"voucher_redeemed"
)
"The number of unique (voucher, counter) pairs which have been redeemed."
-- | Create a new, empty MemoryVoucherDatabase.
memory
::
IO
VoucherDatabaseState
memory
=
do
...
...
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