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
47ca1f36
Commit
47ca1f36
authored
9 years ago
by
Mauricio Giacomini Girardello
Browse files
Options
Downloads
Patches
Plain Diff
refactoring models
parent
8a91291f
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/models/learning_object.rb
+10
-16
10 additions, 16 deletions
app/models/learning_object.rb
app/models/topic.rb
+0
-1
0 additions, 1 deletion
app/models/topic.rb
with
10 additions
and
17 deletions
app/models/learning_object.rb
+
10
−
16
View file @
47ca1f36
...
...
@@ -8,9 +8,7 @@ class LearningObject < ActiveRecord::Base
has_many
:collection_items
,
as: :collectionable
has_many
:collections
,
through: :collection_items
has_many
:complaints
has_many
:attachments
,
class_name:
'LearningObject::Attachment'
,
dependent: :destroy
belongs_to
:publisher
,
polymorphic:
true
...
...
@@ -18,18 +16,20 @@ class LearningObject < ActiveRecord::Base
validates_presence_of
:name
,
:id_dspace
validates_uniqueness_of
:id_dspace
scope
:default_types
,
->
{
group
(
:object_type
).
count
.
reject
{
|
type
,
frequency
|
type
.
blank?
}.
map
{
|
type
,
frequency
|
type
}
}
searchkick
language:
'brazilian'
,
searchable:
[
:name
,
:description
,
:author
,
:object_type
]
def
search_data
{
name:
name
,
description:
description
,
author:
author
,
object_type:
object_type
,
score:
score
,
published_at:
published_at
,
# publisher_id: publisher.id,
topics_name:
topics
.
map
(
&
:name
)
name:
name
,
description:
description
,
author:
author
,
object_type:
object_type
,
score:
score
,
published_at:
published_at
,
# publisher_id: publisher.id,
topics_name:
topics
.
map
(
&
:name
)
}
end
...
...
@@ -49,12 +49,6 @@ class LearningObject < ActiveRecord::Base
get_metadata_value_of
'dc.object.url'
end
def
self
.
default_types
Rails
.
cache
.
fetch
(
"cache/object_type"
,
expires_in:
24
.
hours
)
do
LearningObject
.
group
(
:object_type
).
count
.
reject
{
|
type
,
frequency
|
type
.
blank?
}.
map
{
|
type
,
frequency
|
type
}
end
end
##checks if learning object link to an url.
#returns boolean
def
has_url_reference?
...
...
This diff is collapsed.
Click to expand it.
app/models/topic.rb
+
0
−
1
View file @
47ca1f36
...
...
@@ -3,7 +3,6 @@ class Topic < ActiveRecord::Base
has_many
:topic_relationships
,
foreign_key:
"parent_id"
has_many
:subtopics
,
through: :topic_relationships
,
source: :child
has_many
:topic_highlights
has_many
:highlights
,
through: :topic_highlights
,
source: :learning_object
...
...
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