From 32b6ddf772624e0d25a6d5a250f9e0dbe1ffed50 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 4 Nov 2013 22:50:32 +0100 Subject: [PATCH] hydra-eval-jobs: Support meta.license being a list TODO: PostgreSQL has an array column type, we should use it for the license and maintainers columns. --- src/c/hydra-eval-jobs.cc | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/c/hydra-eval-jobs.cc b/src/c/hydra-eval-jobs.cc index 7da8ad56..616bf52e 100644 --- a/src/c/hydra-eval-jobs.cc +++ b/src/c/hydra-eval-jobs.cc @@ -109,6 +109,22 @@ static int queryMetaFieldInt(MetaInfo & meta, const string & name, int def) } +static string queryMetaField(MetaInfo & meta, const string & name) +{ + string res; + MetaValue value = meta[name]; + if (value.type == MetaValue::tpString) + res = value.stringValue; + else if (value.type == MetaValue::tpStrings) { + foreach (Strings::const_iterator, i, value.stringValues) { + if (res.size() != 0) res += ", "; + res += *i; + } + } + return res; +} + + static void findJobsWrapped(EvalState & state, XMLWriter & doc, const ArgsUsed & argsUsed, const AutoArgs & argsLeft, Value & v, const string & attrPath) @@ -136,8 +152,9 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc, MetaInfo meta = drv.queryMetaInfo(state); xmlAttrs["description"] = queryMetaFieldString(meta, "description"); xmlAttrs["longDescription"] = queryMetaFieldString(meta, "longDescription"); - xmlAttrs["license"] = queryMetaFieldString(meta, "license"); + xmlAttrs["license"] = queryMetaField(meta, "license"); xmlAttrs["homepage"] = queryMetaFieldString(meta, "homepage"); + xmlAttrs["maintainers"] = queryMetaField(meta, "maintainers"); int prio = queryMetaFieldInt(meta, "schedulingPriority", 100); xmlAttrs["schedulingPriority"] = int2String(prio); @@ -148,18 +165,6 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc, int maxsilent = queryMetaFieldInt(meta, "maxSilent", 3600); xmlAttrs["maxSilent"] = int2String(maxsilent); - string maintainers; - MetaValue value = meta["maintainers"]; - if (value.type == MetaValue::tpString) - maintainers = value.stringValue; - else if (value.type == MetaValue::tpStrings) { - foreach (Strings::const_iterator, i, value.stringValues) { - if (maintainers.size() != 0) maintainers += ", "; - maintainers += *i; - } - } - xmlAttrs["maintainers"] = maintainers; - /* If this is an aggregate, then get its constituents. */ Bindings::iterator a = v.attrs->find(state.symbols.create("_hydraAggregate")); if (a != v.attrs->end() && state.forceBool(*a->value)) {