| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $args = trigger.data; |
| 6 | $_Portal = $args._Portal; |
| 7 | $refcons = $args.refcons; |
| 8 | $geto = $args.geto; |
| 9 | $ref = $args.ref; |
| 10 | |
| 11 | $__dada = $refval => |
| 12 | data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]]; |
| 13 | |
| 14 | $Lapse = $__dada( 'Lapse' ); |
| 15 | $Origen = $__dada( 'Origen' ); |
| 16 | $cicle_actual = |
| 17 | 1 + floor( ( timestamp - $Origen ) / $__dada( 'Interval' ) ); |
| 18 | }", |
| 19 | "messages": [ |
| 20 | { |
| 21 | "app": "state", |
| 22 | "state": "{ |
| 23 | response[ 'consulta' ] = $refcons; |
| 24 | |
| 25 | |
| 26 | if ( $refcons == 'Dades_Diposit' ) { |
| 27 | response[ 'Ref' ] = $ref; |
| 28 | response[ 'Quantitat dipositada' ] = $__dada( $ref || '_qt' ); |
| 29 | response[ 'Dipositant' ] = $__dada( $ref || '_dipositant' ); |
| 30 | response[ 'Cicle dipòsit' ] = $__dada( $ref || '_cicle' ); |
| 31 | response[ 'Getó dipòsit' ] = $__dada( $ref || '_geto_diposit' ); |
| 32 | response[ 'Data dipòsit' ] = $__dada( $ref || '_data'); |
| 33 | |
| 34 | response[ 'Taxa' ] = $__dada( $ref || '_taxa' ); |
| 35 | response[ 'Qt conversió' ] = $__dada( $ref || '_qt_conversio' ); |
| 36 | response[ 'Cicle conversió' ] = $__dada( $ref || '_cicle_conversio' ); |
| 37 | response[ 'Cicle actual' ] = $cicle_actual; |
| 38 | } |
| 39 | |
| 40 | |
| 41 | if ( $refcons == 'Dades_Contribucio' ) { |
| 42 | response[ 'Ref' ] = $ref; |
| 43 | response[ 'Quantitat' ] = $__dada( $ref || '_qt' ); |
| 44 | response[ 'Contribuidora' ] = $__dada( $ref || '_contribuidora' ); |
| 45 | response[ 'Cicle contribució' ] = $__dada( $ref || '_cicle' ); |
| 46 | response[ 'Escala contribució' ] = $__dada( $ref || '_escala' ); |
| 47 | response[ 'Interval contribució' ] = $__dada( $ref || '_interval' ); |
| 48 | response[ 'Data contribució' ] = $__dada( $ref || '_data'); |
| 49 | $data_escala = $__dada( 'data_escala_actual' ); |
| 50 | response[ "Segons transcorreguts des del darrer salt d'escala" ] = |
| 51 | timestamp - $data_escala; |
| 52 | $geto_contribucio = $__dada( $ref || '_geto' ); |
| 53 | response[ 'Total Contribucions' ] = |
| 54 | $__dada( 'total_contribucions_' || $geto_contribucio ); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | if ( $refcons == 'Dades_Conversio' |
| 59 | OR $refcons == 'Dades_Retribucio' |
| 60 | OR $refcons == 'Dades_Bonificacio' ) { |
| 61 | response[ 'Ref' ] = $ref; |
| 62 | response[ 'Rebedora' ] = $__dada( $ref || '_rebedora' ); |
| 63 | response[ 'Quantitat' ] = $__dada( $ref || '_qt' ); |
| 64 | response[ 'Data' ] = timestamp_to_string( $__dada( $ref || '_data' ), 'date' ); |
| 65 | if ( $refcons == 'Dades_Conversio' ) |
| 66 | response[ 'Unitat' ] = $__dada( $ref || '_unitat' ); |
| 67 | } |
| 68 | |
| 69 | |
| 70 | if ( $refcons == 'Totals' ) { |
| 71 | $total_donacions = $__dada( 'total_donacions' ) otherwise 0; |
| 72 | $total_assignacions = $__dada( 'total_assignacions' ) otherwise 0; |
| 73 | $total_activacions = $__dada( 'total_activacions_' || $geto ) otherwise 0; |
| 74 | $total_subscripcions = $__dada( 'total_subscripcions_' || $geto ) otherwise 0; |
| 75 | $total_renovacions = $__dada( 'total_renovacions_' || $geto ) otherwise 0; |
| 76 | $total_aportacions = $__dada( 'total_aportacions_' || $geto ) otherwise 0; |
| 77 | $total_diposits = $__dada( 'total_diposits_' || $geto ) otherwise 0; |
| 78 | $total_contribucions = $__dada( 'total_contribucions_' || $geto ) otherwise 0; |
| 79 | $total_conversions = $__dada( 'total_conversions_' || $geto ) otherwise 0; |
| 80 | $total_taxes = $__dada( 'total_taxes_' || $geto ) otherwise 0; |
| 81 | $total_retribucions = $__dada( 'total_retribucions_' || $geto ) otherwise 0; |
| 82 | $total_bonificacions = $__dada( 'total_bonificacions_' || $geto ) otherwise 0; |
| 83 | $total_atribucions = $__dada( 'total_atribucions_' || $geto ) otherwise 0; |
| 84 | $volum_escala = |
| 85 | $total_activacions + $total_subscripcions |
| 86 | + $total_renovacions + $total_aportacions |
| 87 | + $total_contribucions; |
| 88 | |
| 89 | response[ 'Total Donacions' ] = $total_donacions || ' Estels'; |
| 90 | response[ 'Total Assignacions' ] = $total_assignacions || ' Estels'; |
| 91 | response[ 'Total Activacions ' || $geto ] = $total_activacions; |
| 92 | response[ 'Total Subscripcions ' || $geto ] = $total_subscripcions; |
| 93 | response[ 'Total Renovacions ' || $geto ] = $total_renovacions; |
| 94 | response[ 'Total Aportacions ' || $geto ] = $total_aportacions; |
| 95 | response[ 'Total Diposits ' || $geto ] = $total_diposits; |
| 96 | response[ 'Total Contribucions ' || $geto ] = $total_contribucions; |
| 97 | response[ 'Total Conversions ' || $geto ] = $total_conversions; |
| 98 | response[ 'Total Taxes ' || $geto ] = $total_taxes; |
| 99 | response[ 'Total Retribucions ' || $geto ] = $total_retribucions; |
| 100 | response[ 'Total Bonificacions ' || $geto ] = $total_bonificacions; |
| 101 | response[ 'Total Atribucions ' || $geto ] = $total_atribucions; |
| 102 | response[ 'Volum Escala calculat' ] = $volum_escala; |
| 103 | response[ 'Volum Escala registrat' ] = |
| 104 | $__dada( 'volum_escala_' || $geto ) otherwise 0; |
| 105 | } |
| 106 | |
| 107 | |
| 108 | if ( $refcons == 'Cicle_Actual' ) { |
| 109 | $interval = $__dada( 'Interval' ); |
| 110 | $segons_cicle_actual = ( $Origen + ( $cicle_actual * $interval ) ) - timestamp; |
| 111 | $percent_cicle_actual = $segons_cicle_actual / $interval * 100; |
| 112 | response[ 'Cicle actual' ] = $cicle_actual; |
| 113 | response[ 'Data actual' ] = timestamp; |
| 114 | response[ 'Data origen' ] = $Origen; |
| 115 | response[ 'Durada cicles' ] = $interval; |
| 116 | response[ 'Segons restants cicle actual' ] = $segons_cicle_actual; |
| 117 | response[ '% restant del cicle actual' ] = |
| 118 | round( $percent_cicle_actual, 0 ) || ' %'; |
| 119 | } |
| 120 | |
| 121 | |
| 122 | if ( $refcons == 'Escala_Actual' ) { |
| 123 | $escala_actual = $__dada( 'escala_actual_' || $geto ) otherwise 0; |
| 124 | $data_escala = $__dada( 'data_escala_actual_' || $geto ) otherwise 0; |
| 125 | response[ 'Geto' ] = $geto; |
| 126 | response[ 'Escala actual' ] = $escala_actual; |
| 127 | response[ 'Volum Escala actual' ] = $__dada( 'volum_escala_' || $geto ) otherwise 0; |
| 128 | if ( !! $data_escala ) { |
| 129 | response[ "Data del salt d'escala" ] = timestamp_to_string( $data_escala, 'date' ); |
| 130 | response[ 'Data en segons' ] = $data_escala; |
| 131 | response[ 'Segons transcorreguts des de darrer salt escala' ] = timestamp - $data_escala; |
| 132 | } |
| 133 | } |
| 134 | }" |
| 135 | } |
| 136 | ] |
| 137 | } |
| 138 | ] |