Skip to content
Snippets Groups Projects
Commit b86cb1aa authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

fix classification-score sql

parent 8e2d4c1f
No related branches found
No related tags found
No related merge requests found
import("system.logging");
import("system.vars");
import("system.db");
import("Sql_lib");
......@@ -23,18 +24,15 @@ function ClassificationUtils() {}
ClassificationUtils.getScore = function(pClassificationType, pObjectType, pObjectRowid, pClassificationGroup)
{
var score = db.table(SqlCondition.begin()
.andPrepareIfSet("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP", pClassificationGroup)
.andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", pClassificationType)
.andSqlCondition(SqlCondition.begin().orPrepare("CLASSIFICATION.OBJECT_TYPE", pObjectType)
.or("CLASSIFICATION.OBJECT_TYPE is null"))
.andSqlCondition(SqlCondition.begin().orPrepare("CLASSIFICATION.OBJECT_ROWID", pObjectRowid)
.or("CLASSIFICATION.OBJECT_ROWID is null"))
.buildSql("select CLASSIFICATIONTYPE.CLASSIFICATIONGROUP, case when sum(score) is not null then sum(score) else 0 end from CLASSIFICATIONTYPE \n\
left join Classification on CLASSIFICATIONTYPE_ID = CLASSIFICATIONTYPEID \n\
left join CLASSIFICATIONSCORE on CLASSIFICATIONSCORE_ID = CLASSIFICATIONSCOREID",
"1=2",
"group by CLASSIFICATIONTYPE.CLASSIFICATIONGROUP order by CLASSIFICATIONTYPE.CLASSIFICATIONGROUP asc"));
.andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", pClassificationType)
.andPrepareIfSet("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP", pClassificationGroup)
.buildSql("select CLASSIFICATIONTYPE.CLASSIFICATIONGROUP, case when sum(score) is not null then sum(score) else 0 end from CLASSIFICATIONTYPE "
+ db.translateStatement(SqlCondition.begin()
.andPrepare("CLASSIFICATION.OBJECT_TYPE", pObjectType)
.andPrepare("CLASSIFICATION.OBJECT_ROWID", pObjectRowid)
.buildSql("left join CLASSIFICATION on CLASSIFICATIONTYPEID = CLASSIFICATIONTYPE_ID and", "1=2", "", false))
+ "left join CLASSIFICATIONSCORE on CLASSIFICATIONSCORE_ID = CLASSIFICATIONSCOREID", "1=2",
"group by CLASSIFICATIONGROUP order by CLASSIFICATIONGROUP"))
var scores = {};
score.forEach(function(pRow)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment