Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KeyInfo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Marcus Mängel
KeyInfo
Commits
75b993bc
Commit
75b993bc
authored
7 years ago
by
Benny Baumann
Browse files
Options
Downloads
Patches
Plain Diff
add: Read some basic stats from the database
parent
13a978df
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
KeyInfoService/src/KeyDB.hs
+32
-0
32 additions, 0 deletions
KeyInfoService/src/KeyDB.hs
KeyInfoService/src/kishttp.hs
+25
-1
25 additions, 1 deletion
KeyInfoService/src/kishttp.hs
with
57 additions
and
1 deletion
KeyInfoService/src/KeyDB.hs
+
32
−
0
View file @
75b993bc
...
...
@@ -50,6 +50,17 @@ kdb_query_key_id_from_fp_sha3_512 = "SELECT id FROM crypto_key WHERE fp_sha3_512
kdb_query_key_id_from_fp_whirlpool
::
Query
kdb_query_key_id_from_fp_whirlpool
=
"SELECT id FROM crypto_key WHERE fp_whirlpool = ?"
kdb_query_stats_count_collection_group
::
Query
kdb_query_stats_count_collection_group
=
"SELECT COUNT(*) FROM collection_group"
kdb_query_stats_count_collection_archive
::
Query
kdb_query_stats_count_collection_archive
=
"SELECT COUNT(*) FROM collection_archive"
kdb_query_stats_count_document_bundle
::
Query
kdb_query_stats_count_document_bundle
=
"SELECT COUNT(*) FROM crypto_docbundle"
kdb_query_stats_count_document_info
::
Query
kdb_query_stats_count_document_info
=
"SELECT COUNT(*) FROM crypto_document"
kdb_query_stats_count_key_info
::
Query
kdb_query_stats_count_key_info
=
"SELECT COUNT(*) FROM crypto_key"
kdb_query_key_id_from_FP
::
Text
->
IO
Integer
kdb_query_key_id_from_FP
fp
=
do
conn
<-
kdb_connect_default
...
...
@@ -73,3 +84,24 @@ kdb_list_collections_archives = do
where
row2kca
::
(
a
->
b
->
c
->
KeyCollectionArchive
)
->
((
a
,
b
,
c
)
->
KeyCollectionArchive
)
row2kca
f
(
a
,
b
,
c
)
=
f
a
b
c
kdb_stats_query
::
IO
(
Integer
,
Integer
,
Integer
,
Integer
,
Integer
)
kdb_stats_query
=
do
conn
<-
kdb_connect_default
cg
<-
run_one_int_query
conn
kdb_query_stats_count_collection_group
ca
<-
run_one_int_query
conn
kdb_query_stats_count_collection_archive
db
<-
run_one_int_query
conn
kdb_query_stats_count_document_bundle
di
<-
run_one_int_query
conn
kdb_query_stats_count_document_info
ki
<-
run_one_int_query
conn
kdb_query_stats_count_key_info
return
(
cg
,
ca
,
db
,
di
,
ki
)
where
run_one_int_query
::
Connection
->
Query
->
IO
Integer
run_one_int_query
conn
query
=
do
result
<-
real_run_one_int_query
conn
query
let
sanitized
=
Prelude
.
head
$
result
++
[
0
]
return
sanitized
real_run_one_int_query
::
Connection
->
Query
->
IO
[
Integer
]
real_run_one_int_query
conn
q
=
do
result
<-
query_
conn
q
return
$
fmap
(
\
(
Only
x
)
->
x
)
$
result
This diff is collapsed.
Click to expand it.
KeyInfoService/src/kishttp.hs
+
25
−
1
View file @
75b993bc
...
...
@@ -123,7 +123,9 @@ ph_static_css = do
-- "#337ab7"
ph_homePage
::
ServerPart
Response
ph_homePage
=
ph_homePage
=
do
(
stats_cg
,
stats_ca
,
stats_db
,
stats_di
,
stats_ki
)
<-
liftIO
kdb_stats_query
ok
$
template_extra
"Public Key Information Base"
(
link_canonical
"/"
)
$
do
H
.
h1
"Welcome to the Public Key Information Database!"
H
.
p
"This interface provides you with condensed publically available information on public and private keys of various sources."
...
...
@@ -139,6 +141,28 @@ ph_homePage =
"Is your key in the database? Use our "
H
.
a
!
A
.
href
"/search"
$
"search"
" to find out!."
H
.
p
$
do
"Our database currently contains "
H
.
b
!
A
.
class_
"stat count collections"
$
do
H
.
toHtml
$
show
stats_ca
" collections"
" in "
H
.
b
!
A
.
class_
"stat count collectiongroups"
$
do
H
.
toHtml
$
show
stats_cg
" groups"
" with "
H
.
b
!
A
.
class_
"stat count documents"
$
do
H
.
toHtml
$
show
stats_di
" documents"
" in "
H
.
b
!
A
.
class_
"stat count docbundles"
$
do
H
.
toHtml
$
show
stats_db
" bundles"
" totalling "
H
.
b
!
A
.
class_
"stat count keys"
$
do
H
.
toHtml
$
show
stats_ki
" keys"
"."
ph_submit
::
ServerPart
Response
ph_submit
=
msum
[
submit_get
,
submit_post
,
submit_fail
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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