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
95efd9c0
Commit
95efd9c0
authored
9 years ago
by
Mauricio Giacomini Girardello
Browse files
Options
Downloads
Patches
Plain Diff
adding save method for collection repository
parent
aec22e6c
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/controllers/learning_objects_controller.rb
+9
-2
9 additions, 2 deletions
app/controllers/learning_objects_controller.rb
app/repositories/orient_db/collection_repository.rb
+11
-3
11 additions, 3 deletions
app/repositories/orient_db/collection_repository.rb
with
20 additions
and
5 deletions
app/controllers/learning_objects_controller.rb
+
9
−
2
View file @
95efd9c0
class
LearningObjectsController
<
ApplicationController
include
Reportable
before_action
:set_learning_object
,
only:
[
:show
,
:edit
,
:update
,
:destroy
,
:like
]
before_action
:set_learning_object
,
only:
[
:show
,
:edit
,
:update
,
:destroy
,
:like
,
:bookmark
]
after_action
:increment_learning_object_views
,
only:
[
:show
]
before_action
:authenticate_user!
,
except:
[
:index
,
:show
,
:like
]
...
...
@@ -86,7 +86,14 @@ class LearningObjectsController < ApplicationController
learning_object_repository
.
report
current_user
,
@learning_object
,
message
,
description
end
def
bookmark
def
bookmarks
bookmarks
=
current_user
.
bookmarks
bookmarks
.
add
@learning_object
collection_repository
.
save
bookmarks
if
request
.
xhr?
render
json:
{
id:
params
[
:id
]}
end
end
private
...
...
This diff is collapsed.
Click to expand it.
app/repositories/orient_db/collection_repository.rb
+
11
−
3
View file @
95efd9c0
...
...
@@ -6,6 +6,13 @@ module OrientDb
Collection
.
new
(
map_object_hash
(
args
))
end
def
save
(
collection
=
Collection
.
new
)
collection
.
learning_objects
.
each
do
|
learning_object
|
query
=
sprintf
(
"update %s add learning_objects = %s"
,
collection
.
id
,
learning_object
.
id
)
connection
.
command
query
end
end
def
create_bookmarks_collection
(
user
)
bookmarks
=
Bookmarks
.
new
(
owner:
user
)
create
bookmarks
...
...
@@ -30,12 +37,13 @@ module OrientDb
end
def
all
(
user
)
objects
=
build_objects
get_edges_end
(
'BelongsTo'
,
'in'
,
user
.
rid
)
query
=
sprintf
(
"select * from (select expand(in('BelongsTo')) from %s) where name<>'Bookmarks'"
,
user
.
rid
)
objects
=
build_objects
connection
.
query
(
query
)
end
def
bookmarks
(
user
)
# TODO: change bookmarks query
result
=
all
user
query
=
sprintf
(
"select * from (select expand(in('BelongsTo')) from %s) where name='Bookmarks'"
,
user
.
rid
)
result
=
build_objects
(
connection
.
query
(
query
))
if
!
result
.
empty?
return
result
.
first
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