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
5bbbe1b6
Commit
5bbbe1b6
authored
8 years ago
by
Mateus Rambo Strey
Browse files
Options
Downloads
Patches
Plain Diff
remove useless code to production
parent
cc8a9ccd
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
lib/tasks/populator.rake
+0
-53
0 additions, 53 deletions
lib/tasks/populator.rake
lib/tasks/search.rake
+0
-42
0 additions, 42 deletions
lib/tasks/search.rake
with
0 additions
and
95 deletions
lib/tasks/populator.rake
deleted
100755 → 0
+
0
−
53
View file @
cc8a9ccd
namespace
:populator
do
desc
'populate db'
task
learning_object: :environment
do
@date
=
DateTime
.
strptime
(
'05-10-2016'
,
'%d-%m-%Y'
)
[
5_000
,
10_000
].
each
{
|
i
|
populate
(
i
)
}
end
task
print_score: :environment
do
dbs
=
%w(
20161010170343_portalmec_120_users_only
20161010182216_portalmec_500_users_only
20161010204837_portalmec_1000_users_only
)
dbs
.
each
do
|
name
|
Rake
::
Task
[
'db:restore'
].
reenable
Rake
::
Task
[
'db:restore'
].
invoke
(
nil
,
name
)
Rake
::
Task
[
'searchkick:reindex:all'
].
reenable
Rake
::
Task
[
'searchkick:reindex:all'
].
invoke
Rake
::
Task
[
'search:learning_objects'
].
reenable
Rake
::
Task
[
'search:learning_objects'
].
invoke
(
name
)
end
end
private
def
populate
(
user_count
)
Rake
::
Task
[
'db:restore'
].
reenable
Rake
::
Task
[
'db:restore'
].
invoke
(
nil
,
'back'
)
Populator
.
populate
user_count:
user_count
,
date:
@date
# LearningObject.find_each { |lo| LearningObject.reset_counters(lo.id, :views, :likes, :downloads, :shares) }
progressbar
=
ProgressBar
.
create
(
title:
'reset counters from learning objects'
,
total:
LearningObject
.
count
)
Parallel
.
each
(
LearningObject
.
all
,
in_threads:
8
)
do
|
object
|
ActiveRecord
::
Base
.
connection_pool
.
with_connection
do
LearningObject
.
reset_counters
(
object
.
id
,
:views
,
:likes
,
:downloads
,
:shares
)
end
progressbar
.
increment
end
Rake
::
Task
[
'score:calculate_sync'
].
reenable
Rake
::
Task
[
'score:calculate_sync'
].
invoke
(
'LearningObject'
)
Rake
::
Task
[
'score:calculate_sync'
].
reenable
Rake
::
Task
[
'score:calculate_sync'
].
invoke
(
'User'
)
Rake
::
Task
[
'searchkick:reindex:all'
].
reenable
Rake
::
Task
[
'searchkick:reindex:all'
].
invoke
Rake
::
Task
[
'search:learning_objects'
].
reenable
Rake
::
Task
[
'search:learning_objects'
].
invoke
(
"
#{
user_count
}
_users"
)
Rake
::
Task
[
'db:dump'
].
reenable
Rake
::
Task
[
'db:dump'
].
invoke
(
"
#{
user_count
}
_users_only"
)
sleep
(
5
.
seconds
)
end
end
This diff is collapsed.
Click to expand it.
lib/tasks/search.rake
deleted
100644 → 0
+
0
−
42
View file @
cc8a9ccd
namespace
:search
do
desc
'search learning objects'
task
:learning_objects
,
[
:filename
]
=>
:environment
do
|
_t
,
args
|
queries
=
%w(dna molecula floresta matematica)
objects
=
queries
.
map
{
|
q
|
mount_search
(
q
,
'LearningObject'
)
}
File
.
open
(
"
#{
Rails
.
root
}
/db/backups/
#{
args
.
filename
}
_searches.json"
,
'w+'
)
do
|
f
|
f
.
write
(
JSON
.
pretty_generate
(
objects
))
end
end
private
def
mount_search
(
query
,
search_class
)
search
=
SearchService
.
instance
(
Search
.
new
(
query:
query
,
search_class:
search_class
),
nil
).
search
{
query:
query
,
results:
{
elastic:
mount_result
(
LearningObject
.
search
(
query
)),
reputation:
mount_result
(
LearningObject
.
search
(
query
,
order:
{
score:
{
order: :desc
,
unmapped_type: :integer
}
})),
merged:
mount_result
(
search
)
}
}
end
def
mount_result
(
search
,
count
=
50
)
scores
=
Score
.
where
(
'active = true AND score_type @> \'{LearningObject}\''
)
objects
=
search
.
results
.
first
(
count
).
each_with_index
.
map
do
|
object
,
index
|
# score dont exists in ordered searches, so we use sort field
score
=
search
.
response
[
'hits'
][
'hits'
][
index
][
'sort'
]
||
search
.
response
[
'hits'
][
'hits'
][
index
][
'_score'
]
o
=
{
object:
object
.
inspect
,
score:
score
,
reputation_scores:
[]
}
scores
.
each
do
|
s
|
o
[
:reputation_scores
]
<<
{
name:
s
.
name
,
weight:
s
.
weight
,
value:
object
.
try
(
s
.
code
.
to_sym
)
}
end
o
end
{
hits:
search
.
response
[
'hits'
][
'total'
],
objects:
objects
}
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