make the rule to apply year filter more generic, but exclude "indi_pub_downloads_year.year" according to #8135
This commit is contained in:
parent
d399f40ad6
commit
1542d476ae
|
@ -214,59 +214,58 @@ export class IndicatorPath {
|
||||||
}
|
}
|
||||||
export type FilterType = "fundingL0"|"start_year" | "end_year" | "co-funded";
|
export type FilterType = "fundingL0"|"start_year" | "end_year" | "co-funded";
|
||||||
export class IndicatorFilterUtils{
|
export class IndicatorFilterUtils{
|
||||||
static getFilter(field: string, filterType:FilterType) {
|
|
||||||
if(["publication", "software", "dataset", "other", "result"].indexOf(field)!=-1){
|
static getFilter(fieldPath: string, filterType:FilterType) {
|
||||||
return this.getResultFilter(field,filterType);
|
if((filterType == "start_year" || filterType == "end_year") && (fieldPath.indexOf(".year") != -1 || fieldPath.indexOf(".start year") != -1)
|
||||||
}else if (field == "project"){
|
&& fieldPath.indexOf("indi_pub_downloads_year.year") == -1){
|
||||||
|
// make it work for any table with field year or start year no matter the type or the table name
|
||||||
|
//exclude indi_pub_downloads_year.year because it throws errors. when there is a solution remove the exclusion
|
||||||
|
if (filterType == "start_year") {
|
||||||
|
return '{"groupFilters":[{"field":"' + fieldPath + '","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
||||||
|
} else if (filterType == "end_year") {
|
||||||
|
return '{"groupFilters":[{"field":"' + fieldPath + '","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let table = fieldPath&&fieldPath.length > 0? fieldPath.split(".")[0]:"";
|
||||||
|
if(["publication", "software", "dataset", "other", "result"].indexOf(table)!=-1){
|
||||||
|
return this.getResultFilter(table,filterType);
|
||||||
|
}else if (table == "project"){
|
||||||
return this.getProjectFilter(filterType);
|
return this.getProjectFilter(filterType);
|
||||||
}
|
}
|
||||||
else if (field == "country"){
|
else if (table == "country"){
|
||||||
return this.getCountryFilter(filterType);
|
return this.getCountryFilter(filterType);
|
||||||
}else if (field == "organization"){
|
}else if (table == "organization"){
|
||||||
return this.getOrganizationFilter(filterType);
|
return this.getOrganizationFilter(filterType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
static getResultFilter(dbType: string = null, filterType:FilterType) {
|
static getResultFilter(table: string = null, filterType:FilterType) {
|
||||||
|
//works for tables ["publication", "software", "dataset", "other", "result"]
|
||||||
if (filterType == "fundingL0") {
|
if (filterType == "fundingL0") {
|
||||||
if(properties.useOldStatisticsSchema) {
|
if(properties.useOldStatisticsSchema) {
|
||||||
return '{"groupFilters":[{"field":"' + dbType + '.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
return '{"groupFilters":[{"field":"' + table + '.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
||||||
}else{//new statistcs schema
|
}else{//new statistcs schema
|
||||||
return '{"groupFilters":[{"field":"' + dbType + '.project funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
return '{"groupFilters":[{"field":"' + table + '.project funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
||||||
}
|
}
|
||||||
} else if (filterType == "start_year") {
|
|
||||||
return '{"groupFilters":[{"field":"' + dbType + '.year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
||||||
} else if (filterType == "end_year") {
|
|
||||||
return '{"groupFilters":[{"field":"' + dbType + '.year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
||||||
}else if (filterType == "co-funded") {
|
}else if (filterType == "co-funded") {
|
||||||
return '{"groupFilters":[{"field":"' + dbType + '.No of funders","type":">","values":["1"]}],"op":"AND"}';
|
return '{"groupFilters":[{"field":"' + table + '.No of funders","type":">","values":["1"]}],"op":"AND"}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static getProjectFilter( filterType:FilterType) {
|
static getProjectFilter( filterType:FilterType) {
|
||||||
|
//works for table "project"
|
||||||
if (filterType == "fundingL0") {
|
if (filterType == "fundingL0") {
|
||||||
return '{"groupFilters":[{"field":"project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
return '{"groupFilters":[{"field":"project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
||||||
} else if (filterType == "start_year") {
|
|
||||||
return '{"groupFilters":[{"field":"project.start year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
||||||
} else if (filterType == "end_year") {
|
|
||||||
return '{"groupFilters":[{"field":"project.start year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static getOrganizationFilter( filterType:FilterType) {
|
static getOrganizationFilter( filterType:FilterType) {
|
||||||
|
//works for table "organization"
|
||||||
if (filterType == "fundingL0") {
|
if (filterType == "fundingL0") {
|
||||||
return '{"groupFilters":[{"field":"organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
return '{"groupFilters":[{"field":"organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
||||||
} else if (filterType == "start_year") {
|
|
||||||
return '{"groupFilters":[{"field":"organization.project.start year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
||||||
} else if (filterType == "end_year") {
|
|
||||||
return '{"groupFilters":[{"field":"organization.project.start year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static getCountryFilter( filterType:FilterType) {
|
static getCountryFilter( filterType:FilterType) {
|
||||||
|
//works for table "country"
|
||||||
if (filterType == "fundingL0") {
|
if (filterType == "fundingL0") {
|
||||||
return '{"groupFilters":[{"field":"country.organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
return '{"groupFilters":[{"field":"country.organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
||||||
} else if (filterType == "start_year") {
|
|
||||||
return '{"groupFilters":[{"field":"country.organization.project.start year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
||||||
} else if (filterType == "end_year") {
|
|
||||||
return '{"groupFilters":[{"field":"country.organization.project.start year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue