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
db167209
Commit
db167209
authored
8 years ago
by
Lucas Gabriel Lima
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature-tags' of gitlab.c3sl.ufpr.br:portalmec/portalmec into feature-tags
parents
6e474afd
d1a72200
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/services/tags_importer.rb
+15
-2
15 additions, 2 deletions
app/services/tags_importer.rb
with
15 additions
and
2 deletions
app/services/tags_importer.rb
+
15
−
2
View file @
db167209
...
...
@@ -2,10 +2,18 @@ class TagsImporter
attr_accessor
:items
def
import
tags
=
{}
@items
.
each
do
|
learning_object
|
learning_object
.
tag_list
=
parse_tags
learning_object
.
get_metadata_values_of
'dc.subject.category'
learning_object
.
save
categories
=
parse_tags
learning_object
.
get_metadata_values_of
'dc.subject.category'
keywords
=
learning_object
.
get_metadata_values_of
'dc.subject.keyword'
(
categories
+
keywords
).
each
do
|
tag_name
|
unless
tag_exists?
(
tag_name
,
tags
)
tags
[
tag_name
]
=
Tag
.
new
(
name:
tag_name
)
end
end
end
Tag
.
import
tags
.
values
end
private
...
...
@@ -15,4 +23,9 @@ class TagsImporter
values
.
compact
.
each
{
|
value
|
tags
<<
value
.
split
(
'::'
)
}
tags
.
flatten
.
uniq
.
map
(
&
:strip
)
end
def
tag_exists?
(
tag_name
,
tags
)
!
Tag
.
find_by_name
(
tag_name
).
nil?
||
!
tags
[
tag_name
].
nil?
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