Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Harbor 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
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
0efccc36
Commit
0efccc36
authored
9 years ago
by
Mateus Rambo Strey
Browse files
Options
Downloads
Patches
Plain Diff
fix score worker
parent
c1d673ea
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/workers/score_calculator_worker.rb
+16
-14
16 additions, 14 deletions
app/workers/score_calculator_worker.rb
config/sidekiq.yml
+1
-1
1 addition, 1 deletion
config/sidekiq.yml
with
17 additions
and
15 deletions
app/workers/score_calculator_worker.rb
+
16
−
14
View file @
0efccc36
...
@@ -4,26 +4,28 @@ class ScoreCalculatorWorker
...
@@ -4,26 +4,28 @@ class ScoreCalculatorWorker
include
RepositoriesProxy
include
RepositoriesProxy
def
perform
(
rid
)
def
perform
(
rid
)
weights
=
{
"thumbnail"
:
40
,
"likes"
:
20
,
"views"
:
10
,
"description"
:
30
}
object
=
learning_object_repository
.
find
(
rid
)
object
=
learning_object_repository
.
find
(
rid
)
score
=
0
unless
object
.
blank?
weights
=
{
"thumbnail"
:
40
,
"likes"
:
20
,
"views"
:
10
,
"description"
:
30
}
score
=
0
# 40 points if it has thumbnail
# 40 points if it has thumbnail
score
+=
weights
[
:thumbnail
]
unless
object
.
thumbnail
.
empty
?
score
+=
weights
[
:thumbnail
]
unless
object
.
thumbnail
.
blank
?
# 1 point per like
# 1 point per like
likes
=
learning_object_repository
.
count_likes
(
object
)
likes
=
learning_object_repository
.
count_likes
(
object
)
score
+=
(
likes
/
learning_object_repository
.
max_likes
)
*
weights
[
:likes
]
unless
likes
<
1
score
+=
(
likes
/
learning_object_repository
.
max_likes
)
*
weights
[
:likes
]
unless
likes
<
1
# 1 point per view
# 1 point per view
views
=
learning_object_repository
.
count_views
(
object
)
views
=
learning_object_repository
.
count_views
(
object
)
score
+=
(
views
/
learning_object_repository
.
max_views
)
*
weights
[
:views
]
unless
views
<
1
score
+=
(
views
/
learning_object_repository
.
max_views
)
*
weights
[
:views
]
unless
views
<
1
# 30 points if it has description
# 30 points if it has description
score
+=
weights
[
:description
]
unless
object
.
description
.
empty
?
score
+=
weights
[
:description
]
unless
object
.
description
.
blank
?
learning_object_repository
.
update_property
(
object
,
'score'
,
score
)
learning_object_repository
.
update_property
(
object
,
'score'
,
score
)
end
end
end
end
end
This diff is collapsed.
Click to expand it.
config/sidekiq.yml
+
1
−
1
View file @
0efccc36
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
# :daemon: true
# :daemon: true
development
:
&development
development
:
&development
concurrency
:
5
:
concurrency
:
8
host
:
localhost
host
:
localhost
port
:
6379
port
:
6379
...
...
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