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
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
b84762ee
Commit
b84762ee
authored
9 years ago
by
Mateus Rambo Strey
Browse files
Options
Downloads
Patches
Plain Diff
fix score
parent
2b38e16c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/repositories/orient_db/learning_object_repository.rb
+1
-1
1 addition, 1 deletion
app/repositories/orient_db/learning_object_repository.rb
app/workers/score_calculator_worker.rb
+27
-7
27 additions, 7 deletions
app/workers/score_calculator_worker.rb
with
28 additions
and
8 deletions
app/repositories/orient_db/learning_object_repository.rb
+
1
−
1
View file @
b84762ee
...
...
@@ -322,7 +322,7 @@ module OrientDb
end
def
get_max_from_edge
(
edge_class
,
type
)
max
=
connection
.
command
'
SELECT max(#{type}(
"
#{edge_class}
"
).size()) FROM LearningObject
'
max
=
connection
.
command
"
SELECT max(
#{
type
}
(
'
#{
edge_class
}
'
).size()) FROM LearningObject
"
max
[
"result"
][
0
][
"max"
]
end
...
...
This diff is collapsed.
Click to expand it.
app/workers/score_calculator_worker.rb
+
27
−
7
View file @
b84762ee
...
...
@@ -25,17 +25,37 @@ class ScoreCalculatorWorker
score
+=
weights
[
:description
]
unless
object
.
description
.
blank?
# range to 250 points, for normalized likes ( maxLikes/actualLike => [0..1] )
likes
=
learning_object_repository
.
count_likes
(
object
)
score
+=
(
likes
/
learning_object_repository
.
max_likes
)
*
weights
[
:likes
]
unless
likes
<
1
score
+=
divide_by_max
(
learning_object_repository
.
count_likes
(
object
),
learning_object_repository
.
max_likes
,
weights
[
:likes
]
)
# range to 200 points, for normalized views ( maxLikes/actualLike => [0..1] )
views
=
learning_object_repository
.
count_views
(
object
)
score
+=
(
views
/
learning_object_repository
.
max_views
)
*
weights
[
:views
]
unless
views
<
1
downloads
=
learning_object_repository
.
count_downloads
(
object
)
score
+=
(
downloads
/
learning_object_repository
.
max_downloads
)
*
weights
[
:downloads
]
unless
downloads
<
1
score
+=
divide_by_max
(
learning_object_repository
.
count_views
(
object
),
learning_object_repository
.
max_views
,
weights
[
:views
]
)
# downloads
score
+=
divide_by_max
(
learning_object_repository
.
count_downloads
(
object
),
learning_object_repository
.
max_downloads
,
weights
[
:downloads
]
)
learning_object_repository
.
update_property
(
object
,
'score'
,
score
)
end
end
private
def
divide_by_max
(
i
,
max
,
weight
)
if
(
i
>
0
&&
max
>
0
)
&&
(
i
<=
max
)
(
i
/
max
)
*
weight
else
0
end
end
end
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