diff options
author | Jochen Topf <jochen@topf.org> | 2014-09-07 21:11:31 +0200 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2014-09-07 21:11:31 +0200 |
commit | 026bc7cf6cb062254054c70a46bbf4169cf60be0 (patch) | |
tree | 63a2bcbba52e90fc9b8b9e43cb8401f2e61558e2 /sources/projects | |
parent | 6c223d609bb05d1f889f08b0a7031bf62845d1e4 (diff) | |
download | taginfo-026bc7cf6cb062254054c70a46bbf4169cf60be0.tar taginfo-026bc7cf6cb062254054c70a46bbf4169cf60be0.tar.gz |
Add an error log that captures parsing problems of project files.
Diffstat (limited to 'sources/projects')
-rwxr-xr-x | sources/projects/parse.rb | 29 | ||||
-rw-r--r-- | sources/projects/pre.sql | 2 |
2 files changed, 30 insertions, 1 deletions
diff --git a/sources/projects/parse.rb b/sources/projects/parse.rb index 679d9de..1dcbfda 100755 --- a/sources/projects/parse.rb +++ b/sources/projects/parse.rb @@ -40,8 +40,10 @@ projects = db.execute("SELECT id, fetch_json FROM projects WHERE status='OK' ORD projects.each do |id, json| puts " #{id}..." + error_log = '' begin data = JSON.parse(json, { :symbolize_names => true, :create_additions => false }) + db.transaction do |db| db.execute("UPDATE projects SET data_format=?, data_url=? WHERE id=?", data[:data_format], data[:data_url], id) @@ -51,6 +53,27 @@ projects.each do |id, json| if data[:project] p = data[:project] + + if ! p[:name] + error_log += "ERROR: MISSING project.name\n" + end + + if ! p[:description] + error_log += "ERROR: MISSING project.description\n" + end + + if ! p[:project_url] + error_log += "ERROR: MISSING project.project_url\n" + end + + if ! p[:contact_name] + error_log += "ERROR: MISSING project.contact_name\n" + end + + if ! p[:contact_email] + error_log += "ERROR: MISSING project.contact_email\n" + end + db.execute("UPDATE projects SET name=?, description=?, project_url=?, doc_url=?, icon_url=?, contact_name=?, contact_email=? WHERE id=?", p[:name], p[:description], @@ -61,6 +84,8 @@ projects.each do |id, json| p[:contact_email], id ) + else + error_log += "ERROR: MISSING project\n" end if data[:tags] @@ -86,7 +111,11 @@ projects.each do |id, json| on['area'], ); end + else + error_log += "ERROR: MISSING tags\n" end + + db.execute("UPDATE projects SET error_log=? WHERE id=?", error_log, id) end rescue JSON::ParserError db.execute("UPDATE projects SET status='PARSE_ERROR' WHERE id=?", id) diff --git a/sources/projects/pre.sql b/sources/projects/pre.sql index ae55fbf..6f521cd 100644 --- a/sources/projects/pre.sql +++ b/sources/projects/pre.sql @@ -18,10 +18,10 @@ CREATE TABLE projects ( fetch_status TEXT, -- HTTP status code fetch_json TEXT, -- HTTP body status TEXT, -- 'OK', 'FETCH ERROR', 'PARSE ERROR' + error_log TEXT, data_format INTEGER, data_updated DATE, data_url TEXT, - icon BLOB, name TEXT, description TEXT, project_url TEXT, |