VRFS-3936 fine-tuning mobile jtx json format some more
This commit is contained in:
parent
65cb581d3b
commit
ceb2527f56
|
|
@ -78,36 +78,37 @@ namespace :mobile do
|
|||
Z: [],
|
||||
},
|
||||
artists_sections: {
|
||||
'#': [],
|
||||
A: [],
|
||||
B: [],
|
||||
C: [],
|
||||
D: [],
|
||||
E: [],
|
||||
F: [],
|
||||
G: [],
|
||||
H: [],
|
||||
I: [],
|
||||
J: [],
|
||||
K: [],
|
||||
L: [],
|
||||
M: [],
|
||||
N: [],
|
||||
O: [],
|
||||
P: [],
|
||||
Q: [],
|
||||
R: [],
|
||||
S: [],
|
||||
T: [],
|
||||
U: [],
|
||||
V: [],
|
||||
W: [],
|
||||
X: [],
|
||||
Y: [],
|
||||
Z: [],
|
||||
'#': {},
|
||||
A: {},
|
||||
B: {},
|
||||
C: {},
|
||||
D: {},
|
||||
E: {},
|
||||
F: {},
|
||||
G: {},
|
||||
H: {},
|
||||
I: {},
|
||||
J: {},
|
||||
K: {},
|
||||
L: {},
|
||||
M: {},
|
||||
N: {},
|
||||
O: {},
|
||||
P: {},
|
||||
Q: {},
|
||||
R: {},
|
||||
S: {},
|
||||
T: {},
|
||||
U: {},
|
||||
V: {},
|
||||
W: {},
|
||||
X: {},
|
||||
Y: {},
|
||||
Z: {},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
by_artist = {}
|
||||
CSV.foreach(tmp_fname) do |row|
|
||||
jtartist = row[0]
|
||||
jtname = row[1]
|
||||
|
|
@ -128,30 +129,26 @@ namespace :mobile do
|
|||
}
|
||||
jtx_json[:jtx_data_map][jt.id] = jtdata
|
||||
|
||||
begin
|
||||
|
||||
[[jtartist[0], jtx_json[:artists_sections]],
|
||||
[jtname.sub('(','')[0], jtx_json[:songs_sections]]].each do |obj|
|
||||
|
||||
first_char = obj.first.upcase
|
||||
if (1..9) === first_char.to_i || '0' == first_char
|
||||
obj.last[:'#'] << jt.id
|
||||
else
|
||||
obj.last[first_char.to_sym] << jt.id
|
||||
end
|
||||
first_char = jtartist[0].upcase
|
||||
idx = ((1..9) === first_char.to_i || '0' == first_char) ? :'#' : first_char.to_sym
|
||||
artists = jtx_json[:artists_sections][idx]
|
||||
unless artists[jtartist]
|
||||
artists[jtartist] = [jt.id]
|
||||
else
|
||||
artists[jtartist] << jt.id
|
||||
end
|
||||
rescue
|
||||
puts "ERROR: #{$!}: jtname=#{jtname}; jtartist=#{jtartist}"
|
||||
end
|
||||
end
|
||||
|
||||
jtx_json[:songs_section_idx] = jtx_json[:songs_sections].keys.collect do |key|
|
||||
{ key: key, data: [], count: jtx_json[:songs_sections][key].count }
|
||||
|
||||
first_char = jtname.sub('(','')[0].upcase
|
||||
idx = ((1..9) === first_char.to_i || '0' == first_char) ? :'#' : first_char.to_sym
|
||||
jtx_json[:songs_sections][idx] << jt.id
|
||||
end
|
||||
|
||||
jtx_json[:artists_section_idx] = jtx_json[:artists_sections].keys.collect do |key|
|
||||
{ key: key, data: [], count: jtx_json[:artists_sections][key].count }
|
||||
end
|
||||
jtx_json[:songs_section_idx] = jtx_json[:songs_sections].keys.collect do |key|
|
||||
{ key: key, data: [], count: jtx_json[:songs_sections][key].count }
|
||||
end
|
||||
|
||||
File.open("#{Rails.root}/tmp/jtx_indices.json", 'w') do |ff|
|
||||
ff.write jtx_json.to_json
|
||||
|
|
|
|||
Loading…
Reference in New Issue