Skip to content

Commit

Permalink
Merge branch 'reporting' into SDA#53
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanjo Ortilles authored and Juanjo Ortilles committed Jan 26, 2024
2 parents d013847 + 67ef7d0 commit 948ea2f
Show file tree
Hide file tree
Showing 54 changed files with 2,165 additions and 1,247 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ You can see it in action [here](https://www.youtube.com/watch?v=S0wkoeRqz3k&t=5s
To see the technical documentation click [here](docs/technical-docs.md)

## User Documentation
We just created documentation site http://edadoc.jortilles.com/en/index.html#/
<!--this is a test change -->
We just created documentation site http://edadoc.jortilles.com/en/index.html#/



Expand Down
3 changes: 1 addition & 2 deletions eda/docker_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ then
mongosh --eval 'db.createCollection("features")' EDA
mongosh --eval 'db.groups.insert( { "_id": ObjectId("135792467811111111111110"), "role": "EDA_ADMIN_ROLE", "name" : "EDA_ADMIN", "users":[ ObjectId("135792467811111111111111") ] } )' EDA
mongosh --eval 'db.groups.insert( { "_id": ObjectId("135792467811111111111113"), "role": "EDA_USER_ROLE", "name" : "RO", "users":[] } )' EDA

mongosh --eval 'db.groups.insert( { "_id": ObjectId("135792467811111111111115"), "role": "EDA_USER_ROLE", "name" : "EDA_DATASOURCE_CREATOR", "users":[] } )' EDA
mongosh --eval 'db.groups.insert( { "_id": ObjectId("135792467811111111111115"), "role": "EDA_USER_ROLE", "name" : "EDA_DATASOURCE_CREATOR", "users":[] } )' EDA
mongosh --eval 'db.users.insert( { "_id" : ObjectId("135792467811111111111111"), "role" : [ ObjectId("135792467811111111111110") ], "name" : "EDA", "email" : "[email protected]", "password" : "$2a$10$J48xu5KAqobLzvD8FX1LOem7NZUMuXPHID1uSHzbzTbM.wGFPXjb2" } )' EDA
mongosh --eval ' db.users.insert( { "_id" : ObjectId("135792467811111111111112"), "role" : [], "name" : "edaanonim", "email" : "[email protected]", "password" : "$2a$10$ziukAcgjgTe2XPmjO1xsruKJW1HlX0I2pvCiKZHQ69DdaCzgZA4/2" } ) ' EDA

Expand Down
40 changes: 15 additions & 25 deletions eda/eda_api/lib/module/dashboard/dashboard.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,9 @@ export class DashboardController {
// Poso taules prohivides a false
for (let x = 0; x < toJson.ds.model.tables.length; x++) {
try {

if (
uniquesForbiddenTables.includes(
toJson.ds.model.tables[x].table_name


)
) {
toJson.ds.model.tables[x].visible = false
Expand Down Expand Up @@ -318,19 +315,13 @@ export class DashboardController {
i
].content.query.query.fields = MyFields
}





}
}
}
} catch (error) {
console.log('no pannels in dashboard')
}


}


Expand Down Expand Up @@ -637,7 +628,6 @@ export class DashboardController {
*/
static async execQuery(req: Request, res: Response, next: NextFunction) {


try {
const connection = await ManagerConnectionService.getConnection(req.body.model_id);
const dataModel = await connection.getDataSource(req.body.model_id)
Expand Down Expand Up @@ -713,7 +703,12 @@ export class DashboardController {

if (myQuery.fields.length == 0) {
console.log('you cannot see any data');
return res.status(200).json([['noData'], [[]]]);
return res.status(200).json([['noDataAllowed'], [[]]]);
}
if( req.body.query.hasOwnProperty('forSelector') && req.body.query.forSelector===true ){
myQuery.forSelector = true;
}else{
myQuery.forSelector = false;
}

const query = await connection.getQueryBuilded(
Expand All @@ -727,8 +722,8 @@ export class DashboardController {
console.log(
'\x1b[32m%s\x1b[0m',
`QUERY for user ${req.user.name}, with ID: ${req.user._id
}, at: ${formatDate(new Date())} `
}, at: ${formatDate(new Date())} for Dashboard:${req.body.dashboard.dashboard_id
} and Panel:${req.body.dashboard.panel_id} `
)
console.log(query)
console.log(
Expand Down Expand Up @@ -817,7 +812,6 @@ export class DashboardController {
console.log(
'\x1b[32m%s\x1b[0m',
`Date: ${formatDate(new Date())} Dashboard:${req.body.dashboard.dashboard_id
} Panel:${req.body.dashboard.panel_id} DONE\n`
)

Expand All @@ -831,15 +825,14 @@ export class DashboardController {
* Si hay fechas agregadas por mes o dia
* y el flag cumulative está activo se hace la suma acumulativa en todos los campos numéricos
*/
console.log('\x1b[36m%s\x1b[0m', '💾 Chached query 💾')
console.log('\x1b[36m%s\x1b[0m', '💾 Cached query 💾')
DashboardController.cumulativeSum(
cachedQuery.cachedQuery.response,
req.body.query
)
console.log(
'\x1b[32m%s\x1b[0m',
`Date: ${formatDate(new Date())} Dashboard:${req.body.dashboard.dashboard_id
} Panel:${req.body.dashboard.panel_id} DONE\n`
)
return res.status(200).json(cachedQuery.cachedQuery.response)
Expand Down Expand Up @@ -898,7 +891,7 @@ export class DashboardController {
})
if (notAllowedQuery) {
console.log('Not allowed table in query')
return res.status(200).json("[['noData'],[]]")
return res.status(200).json("[['noDataAllowed'],[]]")
} else {
const query = connection.BuildSqlQuery(
req.body.query,
Expand All @@ -919,7 +912,6 @@ export class DashboardController {
console.log(
'\x1b[32m%s\x1b[0m',
`QUERY for user ${req.user.name}, with ID: ${req.user._id
}, at: ${formatDate(new Date())} `
)
console.log(query)
Expand Down Expand Up @@ -1007,21 +999,18 @@ export class DashboardController {
console.log(
'\x1b[32m%s\x1b[0m',
`Date: ${formatDate(new Date())} Dashboard:${req.body.dashboard.dashboard_id
} Panel:${req.body.dashboard.panel_id} DONE\n`
)
//console.log('Query output');
//console.log(output);
return res.status(200).json(output)
} else {
console.log('\x1b[36m%s\x1b[0m', '💾 Chached query 💾')
console.log('\x1b[36m%s\x1b[0m', '💾 Cached query 💾')
console.log(
'\x1b[32m%s\x1b[0m',
`Date: ${formatDate(new Date())} Dashboard:${req.body.dashboard.dashboard_id
} Panel:${req.body.dashboard.panel_id} DONE\n`
)
console.log(cachedQuery.cachedQuery.response);
return res.status(200).json(cachedQuery.cachedQuery.response)
}
}
Expand Down Expand Up @@ -1049,16 +1038,17 @@ export class DashboardController {
// Null values are...NULL
}




return isNotNumeric;

}

/**Check if an user can or not see a data model. */
static securityCheck(dataModel: any, user: any) {

/** un admin lo ve todo */
if( user.role.includes('135792467811111111111110') ){
return true;
}
if(user._id== '135792467811111111111112'){
console.log('Anonymous access');
return true;
Expand Down
3 changes: 2 additions & 1 deletion eda/eda_api/lib/module/datasource/datasource.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class DataSourceController {
}
});

if (users.includes(userID) || roles.length > 0 || allCanSee == 'true') {
if (users.includes(userID) || roles.length > 0 || allCanSee == 'true' || req.user.role.includes('135792467811111111111110') /* admin role los admin lo ven todo*/ ) {
output.push({ _id: e._id, model_name: e.ds.metadata.model_name });
}

Expand Down Expand Up @@ -443,6 +443,7 @@ export class DataSourceController {
searchPath: req.body.schema || manager.GetDefaultSchema(),
user: req.body.user,
password: EnCrypterService.encrypt(req.body.password || 'no'),
poolLimit: req.body.poolLimit,
sid: req.body.sid,
warehouse: req.body.warehouse
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class BigQueryConnection extends AbstractConnection {
column.aggregation_type = AggregationTypes.getValuesForOthers();
}

column.computed_column == 'no' // las posibilidades son no, computed_numeric, computed_string
column.computed_column == 'no' // las posibilidades son no, computed,

column.column_granted_roles = [];
column.row_granted_roles = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class MysqlConnection extends AbstractConnection {
const existingPool = poolManager.getPool(this.config.database);

if (existingPool) {
console.log('same pool')
console.log('same pool');
this.pool = existingPool;
} else {
const mySqlConn: PoolOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ export class OracleConnection extends AbstractConnection {
column.aggregation_type = AggregationTypes.getValuesForOthers();
}

column.computed_column == 'no' // las posibilidades son no, computed_numeric, computed_string
column.computed_column == 'no' // las posibilidades son no, computed,

column.column_granted_roles = [];
column.row_granted_roles = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class PgConnection extends AbstractConnection {
column.aggregation_type = AggregationTypes.getValuesForOthers();
}

column.computed_column == 'no' // las posibilidades son no, computed_numeric, computed_string
column.computed_column == 'no' // las posibilidades son no, computed,

column.column_granted_roles = [];
column.row_granted_roles = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class SnowflakeConnection extends AbstractConnection {
column.aggregation_type = AggregationTypes.getValuesForOthers();
}

column.computed_column == 'no' // las posibilidades son no, computed_numeric, computed_string
column.computed_column == 'no' // las posibilidades son no, computed,

column.column_granted_roles = [];
column.row_granted_roles = [];
Expand Down
27 changes: 27 additions & 0 deletions eda/eda_api/lib/services/custom/custom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Modifica la propiedad `minimumFractionDigits` de un objeto basado en condiciones específicas.
* Se utiliza para forzar a dos decimales los calculos de promedio en SinergiaDA
* https://github.com/SinergiaTIC/SinergiaDA/pull/67
*
* @param {Object} target - El objeto al cual está adjunto el descriptor.
* @param {string} propertyKey - La clave de la propiedad a la que se está adjuntando el descriptor.
* @param {any} descriptor - El descriptor de propiedad para la función.
* @returns {any} El descriptor modificado.
*
* La función intercepta el llamado a la propiedad y modifica el objeto `el`.
* Si `el` no tiene la propiedad `minimumFractionDigits`, se establece a 0.
* Si `el.aggregation_type` es 'avg', se establece `minimumFractionDigits` a 2.
*/
export function muSqlBuilderServiceCustomGetMinFractionDigits(target: Object, propertyKey: string, descriptor: any) {
descriptor.value = function(el: any) {
if (!el.hasOwnProperty("minimumFractionDigits")) {
el.minimumFractionDigits = 0;
}
/*SDA CUSTOM*/ if (el.aggregation_type === "avg") {
/*SDA CUSTOM*/ el.minimumFractionDigits = 2;
/*SDA CUSTOM*/
}
return el;
};
return descriptor;
}
Loading

0 comments on commit 948ea2f

Please sign in to comment.