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
No related tags found
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
# list.each do |learning_object|
# learning_object.inspect <LearningObject model>
# end
def
all
learning_objects_hash
=
connection
.
query
"SELECT FROM LearningObject"
build_objects
(
learning_objects_hash
)
||
[]
end
#
def all
#
learning_objects_hash = connection.query "SELECT FROM LearningObject"
#
build_objects(learning_objects_hash) || []
#
end
# Usage:
# learning_object = repository.for(:learning_objects).get_by_dspace_id 123
...
...
@@ -103,24 +103,37 @@ module OrientDb
FROM index:learningobject_search
WHERE key LUCENE '
#{
qry
}
'
"
,
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
)
||
[]
end
def
build_object
(
args
=
{})
lo
=
nil
unless
args
.
nil?
lo
=
LearningObject
.
new
(
:id
=>
args
[
"@rid"
],
:name
=>
args
[
"name"
],
:description
=>
args
[
"description"
],
:thumbnail
=>
args
[
"thumbnail"
],
:created_at
=>
args
[
"created_at"
],
:id_dspace
=>
args
[
"id_dspace"
],
:type
=>
args
[
"type"
],
:bitstreams
=>
args
[
"bitstreams"
],
:metadata
=>
args
[
"metadata"
],
:last_modified
=>
args
[
"last_modified"
])
lo
.
likes
=
args
.
has_key?
(
"in_Likes"
)
?
args
[
"in_Likes"
].
size
:
0
lo
.
views
=
args
.
has_key?
(
"in_Views"
)
?
args
[
"in_Views"
].
size
:
0
# cache object when build
cache_key
=
args
[
"@rid"
]
+
'/'
+
args
[
"last_modified"
]
lo
=
Rails
.
cache
.
fetch
(
cache_key
,
expires_in:
12
.
hours
)
do
likes
=
args
.
has_key?
(
"in_Likes"
)
?
args
[
"in_Likes"
].
size
:
0
views
=
args
.
has_key?
(
"in_Views"
)
?
args
[
"in_Views"
].
size
:
0
LearningObject
.
new
(
id:
args
[
"@rid"
],
name:
args
[
"name"
],
description:
args
[
"description"
],
thumbnail:
args
[
"thumbnail"
],
created_at:
args
[
"created_at"
],
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
lo
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