Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WTFd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
FOSS-AG
WTFd
Commits
ba8f7f28
Commit
ba8f7f28
authored
Oct 11, 2019
by
Philipp Hochkamp
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix-20-solve-count' into 'master'
added solvecount to detail view Closes
#20
See merge request
!17
parents
432b3029
8e3e05b8
No related branches found
No related tags found
1 merge request
!17
added solvecount to detail view
Pipeline
#1822
passed with warnings
Oct 11, 2019
Stage: test
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/orm.go
+13
-3
13 additions, 3 deletions
internal/orm.go
internal/server.go
+1
-1
1 addition, 1 deletion
internal/server.go
with
14 additions
and
4 deletions
internal/orm.go
+
13
−
3
View file @
ba8f7f28
...
@@ -3,9 +3,9 @@ package wtfd
...
@@ -3,9 +3,9 @@ package wtfd
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
"golang.org/x/crypto/bcrypt"
"github.com/go-xorm/xorm"
"github.com/go-xorm/xorm"
_
"github.com/mattn/go-sqlite3"
// needed for xorm
_
"github.com/mattn/go-sqlite3"
// needed for xorm
"golang.org/x/crypto/bcrypt"
"os"
"os"
"xorm.io/core"
"xorm.io/core"
)
)
...
@@ -63,7 +63,6 @@ func Login(username, passwd string) error {
...
@@ -63,7 +63,6 @@ func Login(username, passwd string) error {
}
}
// NewUser creates a new user object
// NewUser creates a new user object
func
NewUser
(
name
,
password
,
displayname
string
)
(
User
,
error
)
{
func
NewUser
(
name
,
password
,
displayname
string
)
(
User
,
error
)
{
if
Contains
(
name
,
displayname
)
{
if
Contains
(
name
,
displayname
)
{
...
@@ -78,13 +77,13 @@ func NewUser(name, password, displayname string) (User, error) {
...
@@ -78,13 +77,13 @@ func NewUser(name, password, displayname string) (User, error) {
return
User
{
Name
:
name
,
Hash
:
hash
,
DisplayName
:
displayname
},
nil
return
User
{
Name
:
name
,
Hash
:
hash
,
DisplayName
:
displayname
},
nil
}
}
// Contains looks if a username is in the datenbank
// Contains looks if a username is in the datenbank
func
Contains
(
username
,
displayname
string
)
bool
{
func
Contains
(
username
,
displayname
string
)
bool
{
count
,
_
:=
ormUserExists
(
User
{
Name
:
username
,
DisplayName
:
displayname
})
count
,
_
:=
ormUserExists
(
User
{
Name
:
username
,
DisplayName
:
displayname
})
return
count
return
count
}
}
// Get gets username based on username
// Get gets username based on username
func
Get
(
username
string
)
(
User
,
error
)
{
func
Get
(
username
string
)
(
User
,
error
)
{
user
,
err
:=
ormLoadUser
(
username
)
user
,
err
:=
ormLoadUser
(
username
)
...
@@ -148,6 +147,17 @@ func ormNewUser(user User) error {
...
@@ -148,6 +147,17 @@ func ormNewUser(user User) error {
return
err
return
err
}
}
// ormGetSolveCount returns the number of solves for the Challenge chall
func
ormGetSolveCount
(
chall
Challenge
)
int64
{
count
,
err
:=
engine
.
Where
(
"ChallengeName = ?"
,
chall
.
Name
)
.
Count
(
_ORMChallengesByUser
{})
if
err
!=
nil
{
return
0
}
return
count
}
// Update existing user record (user.Name) with other values from user
// Update existing user record (user.Name) with other values from user
// Solved challenges WON'T be updated (refer to ormChallengeSolved)
// Solved challenges WON'T be updated (refer to ormChallengeSolved)
func
ormUpdateUser
(
user
User
)
error
{
func
ormUpdateUser
(
user
User
)
error
{
...
...
This diff is collapsed.
Click to expand it.
internal/server.go
+
1
−
1
View file @
ba8f7f28
...
@@ -332,7 +332,7 @@ func detailview(w http.ResponseWriter, r *http.Request) {
...
@@ -332,7 +332,7 @@ func detailview(w http.ResponseWriter, r *http.Request) {
w
.
WriteHeader
(
http
.
StatusBadRequest
)
w
.
WriteHeader
(
http
.
StatusBadRequest
)
return
return
}
}
_
,
_
=
fmt
.
Fprintf
(
w
,
"%s
"
,
chall
.
Description
)
_
,
_
=
fmt
.
Fprintf
(
w
,
"%s
<br><p>Solves: %d</p>"
,
chall
.
Description
,
ormGetSolveCount
(
*
chall
)
)
}
}
...
...
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