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
2fdffc81
Commit
2fdffc81
authored
9 years ago
by
Mateus Rambo Strey
Browse files
Options
Downloads
Patches
Plain Diff
add learning object cache
parent
bea73b88
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/repositories/orient_db/learning_object_repository.rb
+29
-16
29 additions, 16 deletions
app/repositories/orient_db/learning_object_repository.rb
with
29 additions
and
16 deletions
app/repositories/orient_db/learning_object_repository.rb
+
29
−
16
View file @
2fdffc81
...
@@ -47,10 +47,10 @@ module OrientDb
...
@@ -47,10 +47,10 @@ module OrientDb
# list.each do |learning_object|
# list.each do |learning_object|
# learning_object.inspect <LearningObject model>
# learning_object.inspect <LearningObject model>
# end
# end
def
all
#
def all
learning_objects_hash
=
connection
.
query
"SELECT FROM LearningObject"
#
learning_objects_hash = connection.query "SELECT FROM LearningObject"
build_objects
(
learning_objects_hash
)
||
[]
#
build_objects(learning_objects_hash) || []
end
#
end
# Usage:
# Usage:
# learning_object = repository.for(:learning_objects).get_by_dspace_id 123
# learning_object = repository.for(:learning_objects).get_by_dspace_id 123
...
@@ -103,24 +103,37 @@ module OrientDb
...
@@ -103,24 +103,37 @@ module OrientDb
FROM index:learningobject_search
FROM index:learningobject_search
WHERE key LUCENE '
#{
qry
}
'
WHERE key LUCENE '
#{
qry
}
'
"
,
limit:
10000
"
,
limit:
10000
# learning_objects_hash = connection.query "#SELECT @rid.asString() FROM (
# SELECT EXPAND(rid) FROM index:learningobject_search
# WHERE key LUCENE '#{qry}'
# )", limit: 10000
build_objects
(
learning_objects_hash
)
||
[]
build_objects
(
learning_objects_hash
)
||
[]
end
end
def
build_object
(
args
=
{})
def
build_object
(
args
=
{})
lo
=
nil
lo
=
nil
unless
args
.
nil?
unless
args
.
nil?
lo
=
LearningObject
.
new
(
:id
=>
args
[
"@rid"
],
# cache object when build
:name
=>
args
[
"name"
],
cache_key
=
args
[
"@rid"
]
+
'/'
+
args
[
"last_modified"
]
:description
=>
args
[
"description"
],
lo
=
Rails
.
cache
.
fetch
(
cache_key
,
expires_in:
12
.
hours
)
do
:thumbnail
=>
args
[
"thumbnail"
],
likes
=
args
.
has_key?
(
"in_Likes"
)
?
args
[
"in_Likes"
].
size
:
0
:created_at
=>
args
[
"created_at"
],
views
=
args
.
has_key?
(
"in_Views"
)
?
args
[
"in_Views"
].
size
:
0
:id_dspace
=>
args
[
"id_dspace"
],
LearningObject
.
new
(
:type
=>
args
[
"type"
],
id:
args
[
"@rid"
],
:bitstreams
=>
args
[
"bitstreams"
],
name:
args
[
"name"
],
:metadata
=>
args
[
"metadata"
],
description:
args
[
"description"
],
:last_modified
=>
args
[
"last_modified"
])
thumbnail:
args
[
"thumbnail"
],
lo
.
likes
=
args
.
has_key?
(
"in_Likes"
)
?
args
[
"in_Likes"
].
size
:
0
created_at:
args
[
"created_at"
],
lo
.
views
=
args
.
has_key?
(
"in_Views"
)
?
args
[
"in_Views"
].
size
:
0
id_dspace:
args
[
"id_dspace"
],
type:
args
[
"type"
],
bitstreams:
args
[
"bitstreams"
],
metadata:
args
[
"metadata"
],
last_modified:
args
[
"last_modified"
],
likes:
likes
,
views:
views
)
end
end
end
lo
lo
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