#!/usr/bin/ruby # # This file is part of centurio.work/was. # # centurio.work/ing/commands is free software: you can redistribute it and/or # modify it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # centurio.work/ing/commands is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along with # centurio.work/ing/commands (file COPYING in the main directory). If not, see # . require 'rubygems' require 'json' require 'riddl/server' require 'riddl/client' require 'fileutils' require 'nokogiri' require 'sqlite3' require 'net/http' require 'uri' $db = SQLite3::Database.open 'data.db' #ADD ST entry to all entries searchstring = "SELECT DISTINCT __orderID__, alldata FROM Entries" result = $db.execute searchstring; result.each do |item| key = item[0] newalldata = item[1] pp key pp newalldata thaData = JSON.parse(newalldata) thaData["DZ-M"] = 0; thaData["RDZ-M"] = 0; 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"] newalldata = {} sort_order.each{|k| newalldata[k] = thaData[k.to_s] } #pp newalldata.to_json $db.execute("UPDATE Entries SET alldata = ? WHERE __orderID__ = ?", newalldata.to_json, key ) end