aboutsummaryrefslogtreecommitdiff
path: root/sources/projects
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2014-09-07 21:11:31 +0200
committerJochen Topf <jochen@topf.org>2014-09-07 21:11:31 +0200
commit026bc7cf6cb062254054c70a46bbf4169cf60be0 (patch)
tree63a2bcbba52e90fc9b8b9e43cb8401f2e61558e2 /sources/projects
parent6c223d609bb05d1f889f08b0a7031bf62845d1e4 (diff)
downloadtaginfo-026bc7cf6cb062254054c70a46bbf4169cf60be0.tar
taginfo-026bc7cf6cb062254054c70a46bbf4169cf60be0.tar.gz
Add an error log that captures parsing problems of project files.
Diffstat (limited to 'sources/projects')
-rwxr-xr-xsources/projects/parse.rb29
-rw-r--r--sources/projects/pre.sql2
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,