addCollumnToJson.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/ruby
  2. #
  3. # This file is part of centurio.work/was.
  4. #
  5. # centurio.work/ing/commands is free software: you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or (at your
  8. # option) any later version.
  9. #
  10. # centurio.work/ing/commands is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  13. # Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License along with
  16. # centurio.work/ing/commands (file COPYING in the main directory). If not, see
  17. # <http://www.gnu.org/licenses/>.
  18. require 'rubygems'
  19. require 'json'
  20. require 'riddl/server'
  21. require 'riddl/client'
  22. require 'fileutils'
  23. require 'nokogiri'
  24. require 'sqlite3'
  25. require 'net/http'
  26. require 'uri'
  27. $db = SQLite3::Database.open 'data.db'
  28. #ADD ST entry to all entries
  29. searchstring = "SELECT DISTINCT __orderID__, alldata FROM Entries"
  30. result = $db.execute searchstring;
  31. result.each do |item|
  32. key = item[0]
  33. newalldata = item[1]
  34. pp key
  35. pp newalldata
  36. thaData = JSON.parse(newalldata)
  37. thaData["DZ-M"] = 0;
  38. thaData["RDZ-M"] = 0;
  39. sort_order = [:"gesamt", :"KZ-S", :"RKZ-S", :"HZ-S", :"RHZ-S", :"DZ-S", :"DZ-M", :"RDZ-S", :"RDZ-M", :"HM24-S", :"MB19", :"MB22", :"MB23CH", :"MB27", :"SKA", :"A0V", :"AZ25-FP", :"AZ37", :"IZ37", :"AZ38", :"IZ38", :"AZ29-RC1"]
  40. newalldata = {}
  41. sort_order.each{|k| newalldata[k] = thaData[k.to_s] }
  42. #pp newalldata.to_json
  43. $db.execute("UPDATE Entries SET alldata = ? WHERE __orderID__ = ?", newalldata.to_json, key )
  44. end