close #7 and make tags all lowercase
This commit is contained in:
parent
a2249a48a3
commit
b0be6d6b6e
@ -2,14 +2,12 @@ process_tags = (tags_str) ->
|
|||||||
-- split into a table to garuntee uniqueness
|
-- split into a table to garuntee uniqueness
|
||||||
unique = {}
|
unique = {}
|
||||||
for tag in tags_str\gmatch "%S+"
|
for tag in tags_str\gmatch "%S+"
|
||||||
unique[tag] = true
|
unique[tag\lower!] = true
|
||||||
-- place back into an array
|
-- place back into an array
|
||||||
taglist = {}
|
taglist = {}
|
||||||
for tag in pairs unique
|
for tag in pairs unique
|
||||||
table.insert taglist, tag
|
table.insert taglist, tag
|
||||||
-- sort case-sensitively and then case-insensitively (so capitalized tags appear before their uncapitalized counterparts)
|
|
||||||
table.sort taglist
|
table.sort taglist
|
||||||
table.sort taglist, (a, b) -> a\lower! < b\lower!
|
|
||||||
return " #{table.concat taglist, " "} "
|
return " #{table.concat taglist, " "} "
|
||||||
|
|
||||||
update_track = (user_input) ->
|
update_track = (user_input) ->
|
||||||
|
@ -27,6 +27,7 @@ import Tracks from require "models"
|
|||||||
}
|
}
|
||||||
add_column "tracks", unpack column
|
add_column "tracks", unpack column
|
||||||
[3]: =>
|
[3]: =>
|
||||||
|
-- NOTE: bad migration!
|
||||||
for track in *Tracks\select "*"
|
for track in *Tracks\select "*"
|
||||||
tags = ""
|
tags = ""
|
||||||
for field in *{"artist", "mood", "link", "genre"}
|
for field in *{"artist", "mood", "link", "genre"}
|
||||||
@ -35,4 +36,15 @@ import Tracks from require "models"
|
|||||||
if #tags > 0
|
if #tags > 0
|
||||||
track.tags = process_tags trim(track.tags or "untagged") .. tags
|
track.tags = process_tags trim(track.tags or "untagged") .. tags
|
||||||
track\update "tags"
|
track\update "tags"
|
||||||
|
[4]: =>
|
||||||
|
-- WARNING: removes all tags!
|
||||||
|
for track in *Tracks\select "*"
|
||||||
|
tags = ""
|
||||||
|
for field in *{"artist", "mood", "link", "genre"}
|
||||||
|
if track[field] and #track[field] > 0
|
||||||
|
tags ..= " #{field}:#{track[field]}"
|
||||||
|
if #tags > 0
|
||||||
|
track.tags = process_tags "untagged" .. tags
|
||||||
|
else
|
||||||
|
track.tags = " untagged "
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user