This is the codeAbility Sharing Platform! Learn more about the
codeAbility Sharing Platform
.
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
codeAbility Sharing Platform
Manage
Activity
Members
Labels
Plan
Issues
43
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
development
sharing
codeAbility Sharing Platform
Commits
1fffc6cd
Commit
1fffc6cd
authored
3 years ago
by
Eduard Frankford
Browse files
Options
Downloads
Patches
Plain Diff
refactored the searchUserStatistics method
parent
8228d7a6
2 merge requests
!188
Merging Peer Reviewing et. al to Master
,
!164
211 peer reviewing functionality
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/at/ac/uibk/gitsearch/web/rest/AchievementResource.java
+6
-15
6 additions, 15 deletions
...va/at/ac/uibk/gitsearch/web/rest/AchievementResource.java
with
6 additions
and
15 deletions
src/main/java/at/ac/uibk/gitsearch/web/rest/AchievementResource.java
+
6
−
15
View file @
1fffc6cd
...
@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestParam;
...
@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
at.ac.uibk.gitsearch.es.model.DocumentInfo
;
import
at.ac.uibk.gitsearch.es.model.DocumentInfo
;
import
at.ac.uibk.gitsearch.service.AchievementService
;
import
at.ac.uibk.gitsearch.service.SearchService
;
import
at.ac.uibk.gitsearch.service.SearchService
;
import
at.ac.uibk.gitsearch.service.StatisticsService
;
import
at.ac.uibk.gitsearch.service.StatisticsService
;
import
at.ac.uibk.gitsearch.service.UserService
;
import
at.ac.uibk.gitsearch.service.UserService
;
...
@@ -53,15 +54,18 @@ public class AchievementResource {
...
@@ -53,15 +54,18 @@ public class AchievementResource {
private
final
SearchService
searchService
;
private
final
SearchService
searchService
;
private
final
AchievementService
achievementService
;
private
final
StatisticsService
statisticsService
;
private
final
StatisticsService
statisticsService
;
private
final
UserService
userService
;
private
final
UserService
userService
;
public
AchievementResource
(
SearchService
searchService
,
StatisticsService
statisticsService
,
UserService
userService
)
{
public
AchievementResource
(
SearchService
searchService
,
StatisticsService
statisticsService
,
UserService
userService
,
AchievementService
achievementService
)
{
this
.
searchService
=
searchService
;
this
.
searchService
=
searchService
;
this
.
statisticsService
=
statisticsService
;
this
.
statisticsService
=
statisticsService
;
this
.
userService
=
userService
;
this
.
userService
=
userService
;
this
.
achievementService
=
achievementService
;
}
}
@GetMapping
(
"/user/achievements"
)
@GetMapping
(
"/user/achievements"
)
...
@@ -69,20 +73,7 @@ public class AchievementResource {
...
@@ -69,20 +73,7 @@ public class AchievementResource {
public
ResponseEntity
<
StatisticsDTO
>
searchUserStatistics
()
throws
IOException
{
public
ResponseEntity
<
StatisticsDTO
>
searchUserStatistics
()
throws
IOException
{
String
email
=
userService
.
getUserWithAuthorities
().
get
().
getEmail
();
String
email
=
userService
.
getUserWithAuthorities
().
get
().
getEmail
();
log
.
debug
(
"REST request to search statistics for user {}"
,
email
);
log
.
debug
(
"REST request to search statistics for user {}"
,
email
);
SearchResultsDTO
results
=
searchService
.
searchResultForAuthorEmail
(
email
,
1000
);
StatisticsDTO
toReturn
=
achievementService
.
searchUserStatistics
(
email
);
int
totalAmountOfViews
=
0
;
int
totalAmountOfDownloads
=
0
;
for
(
SearchResultDTO
result
:
results
.
getSearchResult
())
{
Optional
<
StatisticsDTO
>
statisticsDTO
=
statisticsService
.
findOneByExerciseID
((
Long
.
parseLong
(
result
.
getExerciseId
())));
if
(
statisticsDTO
.
isPresent
())
{
StatisticsDTO
newStats
=
statisticsDTO
.
get
();
totalAmountOfViews
+=
newStats
.
getViews
();
totalAmountOfDownloads
+=
newStats
.
getDownloads
();
}
}
StatisticsDTO
toReturn
=
new
StatisticsDTO
();
toReturn
.
setViews
(
totalAmountOfViews
);
toReturn
.
setDownloads
(
totalAmountOfDownloads
);
return
new
ResponseEntity
<
StatisticsDTO
>(
toReturn
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
StatisticsDTO
>(
toReturn
,
HttpStatus
.
OK
);
...
...
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