| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Consultes_Accions'; |
| 6 | |
| 7 | $args = trigger.data; |
| 8 | $_Portal = $args._Portal; |
| 9 | $refcons = $args.refcons; |
| 10 | $geto = $args.geto; |
| 11 | $ref = $args.ref; |
| 12 | |
| 13 | $__dada = $refval => |
| 14 | data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]]; |
| 15 | |
| 16 | $Lapse = $__dada( 'Lapse' ); |
| 17 | $Origen = $__dada( 'Origen' ); |
| 18 | $cicle_actual = |
| 19 | 1 + floor( ( timestamp - $Origen ) / $__dada( 'Interval' ) ); |
| 20 | }", |
| 21 | "messages": [ |
| 22 | { |
| 23 | "app": "state", |
| 24 | "state": "{ |
| 25 | response[ 'consulta' ] = $refcons; |
| 26 | |
| 27 | |
| 28 | |
| 29 | if ( $refcons == 'Dades_Node' ) { |
| 30 | $ref_activacio = 'activacio_' || $geto || '_' || $args.adr; |
| 31 | $ord_activacio = $__dada( $ref_activacio ); |
| 32 | $data_activacio = $__dada( $ord_activacio || '_data' ); |
| 33 | |
| 34 | |
| 35 | if ( !! $data_activacio ) { |
| 36 | response[ 'Node ' || $args.adr || ' activat per a' ] = $geto; |
| 37 | response[ 'Nom node' ] = $__dada( $ord_activacio || '_nom' ); |
| 38 | response[ 'Aportació per activació' ] = $__dada( $ord_activacio || '_qt' ); |
| 39 | response[ 'Cicle activació' ] = $__dada( $ord_activacio || '_cicle' ); |
| 40 | response[ 'Escala activació' ] = $__dada( $ord_activacio || '_escala' ); |
| 41 | response[ 'Interval activació' ] = $__dada( $ord_activacio || '_interval' ); |
| 42 | response[ 'Data activació' ] = timestamp_to_string( $data_activacio, 'date' ); |
| 43 | |
| 44 | $ref_subscripcio = 'subscripcio_' || $geto || '_' || $args.adr; |
| 45 | $ord_subscripcio = $__dada( $ref_subscripcio ); |
| 46 | $data_subscripcio = $__dada( $ord_subscripcio || '_data' ); |
| 47 | |
| 48 | if ( !! $data_subscripcio ) { |
| 49 | response[ 'Subscripció per a ' || $geto || ' de' ] = $args.adr; |
| 50 | response[ 'Nom subscripció' ] = $__dada( $ord_subscripcio || '_nom' ); |
| 51 | response[ '% que dona' ] = $__dada( $ord_subscripcio || '_dona' ); |
| 52 | response[ 'Cicle subscripció' ] = $__dada( $ord_subscripcio || '_cicle' ); |
| 53 | response[ 'Data subscripció' ] = timestamp_to_string( $data_subscripcio, 'date' ); |
| 54 | response[ 'Total donat' ] = |
| 55 | $__dada( 'total_donat_' || $geto || '_' || $args.adr ); |
| 56 | |
| 57 | $ref_renovacio = 'renovacio_' || $geto || '_' || $args.adr; |
| 58 | $ord_renovacio = $__dada( $ref_renovacio ); |
| 59 | response[ 'Darrer cicle renovat' ] = |
| 60 | $__dada( $ord_renovacio || '_cicle' ); |
| 61 | } |
| 62 | |
| 63 | $ref_avis = 'avis_' || $geto || '_' || $args.adr; |
| 64 | $temps_avis = $__dada( $ref_avis ); |
| 65 | if ( $temps_avis ) { |
| 66 | $avis_es_actual = $temps_avis + ( $Lapse * 2 ) < timestamp; |
| 67 | if ( $avis_es_actual ) { |
| 68 | response[ 'Avís' ] = $__dada( $ref_avis || '_text' ); |
| 69 | response[ 'Data' ] = timestamp_to_string( $temps_avis, 'date' ); |
| 70 | response[ 'Rebot' ] = $__dada( $ref_avis || '_rebot' ); |
| 71 | } |
| 72 | } |
| 73 | } else { |
| 74 | response[ 'adr ' || $args.adr ] = 'NO activada per a ' || $geto; |
| 75 | } |
| 76 | response[ 'Cicle actual' ] = $cicle_actual; |
| 77 | } |
| 78 | |
| 79 | |
| 80 | if ( $refcons == 'Dades_Diposit' ) { |
| 81 | response[ 'Ref' ] = $ref; |
| 82 | response[ 'Quantitat dipositada' ] = $__dada( $ref || '_qt' ); |
| 83 | response[ 'Dipositant' ] = $__dada( $ref || '_dipositant' ); |
| 84 | response[ 'Cicle dipòsit' ] = $__dada( $ref || '_cicle' ); |
| 85 | response[ 'Getó dipòsit' ] = $__dada( $ref || '_geto_diposit' ); |
| 86 | response[ 'Data dipòsit' ] = $__dada( $ref || '_data'); |
| 87 | |
| 88 | response[ 'Taxa' ] = $__dada( $ref || '_taxa' ); |
| 89 | response[ 'Qt conversió' ] = $__dada( $ref || '_qt_conversio' ); |
| 90 | response[ 'Cicle conversió' ] = $__dada( $ref || '_cicle_conversio' ); |
| 91 | response[ 'Cicle actual' ] = $cicle_actual; |
| 92 | } |
| 93 | |
| 94 | |
| 95 | if ( $refcons == 'Dades_Contribucio' ) { |
| 96 | response[ 'Ref' ] = $ref; |
| 97 | response[ 'Quantitat' ] = $__dada( $ref || '_qt' ); |
| 98 | response[ 'Contribuidora' ] = $__dada( $ref || '_contribuidora' ); |
| 99 | response[ 'Cicle contribució' ] = $__dada( $ref || '_cicle' ); |
| 100 | response[ 'Escala contribució' ] = $__dada( $ref || '_escala' ); |
| 101 | response[ 'Interval contribució' ] = $__dada( $ref || '_interval' ); |
| 102 | response[ 'Data contribució' ] = $__dada( $ref || '_data'); |
| 103 | $data_escala = $__dada( 'data_escala_actual' ); |
| 104 | response[ "Segons transcorreguts des del darrer salt d'escala" ] = |
| 105 | timestamp - $data_escala; |
| 106 | response[ 'Total Contribucions' ] = $__dada( 'total_contribucions_estels' ); |
| 107 | } |
| 108 | |
| 109 | |
| 110 | if ( $refcons == 'Dades_Conversio' OR $refcons == 'Dades_Retribucio' ) { |
| 111 | response[ 'Ref' ] = $ref; |
| 112 | response[ 'Rebedora' ] = $__dada( $ref || '_rebedora' ); |
| 113 | response[ 'Quantitat' ] = $__dada( $ref || '_qt' ); |
| 114 | response[ 'Data' ] = timestamp_to_string( $__dada( $ref || '_data' ), 'date' ); |
| 115 | if ( $refcons == 'Dades_Conversio' ) |
| 116 | response[ 'Unitat' ] = $__dada( $ref || '_unitat' ); |
| 117 | } |
| 118 | |
| 119 | |
| 120 | if ( $refcons == 'Totals' ) { |
| 121 | $total_geto = $__dada( 'total_' || $geto ); |
| 122 | $total_FOP = $__dada( 'total_FOP_' || $geto ); |
| 123 | $total_donat = $__dada( 'total_donat_' || $geto ); |
| 124 | $total_activacions = $__dada( 'total_activacions_' || $geto ); |
| 125 | $total_subscripcions = $__dada( 'total_subscripcions_' || $geto ); |
| 126 | $total_renovacions = $__dada( 'total_renovacions_' || $geto ); |
| 127 | $total_diposits = $__dada( 'total_diposits_' || $geto ); |
| 128 | $total_contribucions = $__dada( 'total_contribucions_estels' ); |
| 129 | $total_conversions = $__dada( 'total_conversions_' || $geto ); |
| 130 | $total_taxes = $__dada( 'total_taxes_' || $geto ); |
| 131 | $total_retribucions = $__dada( 'total_retribucions' ); |
| 132 | $total_assignacions = $__dada( 'total_assignacions' ); |
| 133 | |
| 134 | response[ 'Total Getó' ] = $total_geto; |
| 135 | response[ 'Total FOP' ] = $total_FOP; |
| 136 | response[ 'Total Activacions' ] = $total_activacions; |
| 137 | response[ 'Total Subscripcions' ] = $total_subscripcions; |
| 138 | response[ 'Total Renovacions' ] = $total_renovacions; |
| 139 | response[ 'Total Donat' ] = $total_donat; |
| 140 | response[ 'Total Diposits' ] = $total_diposits; |
| 141 | response[ 'Total Contribucions' ] = $total_contribucions; |
| 142 | response[ 'Total Conversions' ] = $total_conversions; |
| 143 | response[ 'Total Taxes' ] = $total_taxes; |
| 144 | response[ 'Total Retribucions' ] = $total_retribucions; |
| 145 | response[ 'Total Assignacions' ] = $total_assignacions; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | if ( $refcons == 'Cicle_Actual' ) { |
| 150 | $interval = $__dada( 'Interval' ); |
| 151 | $segons_cicle_actual = ( $Origen + ( $cicle_actual * $interval ) ) - timestamp; |
| 152 | $percent_cicle_actual = $segons_cicle_actual / $interval * 100; |
| 153 | response[ 'Cicle actual' ] = $cicle_actual; |
| 154 | response[ 'Data actual' ] = timestamp; |
| 155 | response[ 'Data origen' ] = $Origen; |
| 156 | response[ 'Durada cicles' ] = $interval; |
| 157 | response[ 'Segons restants cicle actual' ] = $segons_cicle_actual; |
| 158 | response[ '% restant del cicle actual' ] = |
| 159 | round( $percent_cicle_actual, 0 ) || ' %'; |
| 160 | } |
| 161 | |
| 162 | |
| 163 | if ( $refcons == 'Escala_Actual' ) { |
| 164 | $escala_actual = $__dada( 'escala_actual' ); |
| 165 | $data_escala = $__dada( 'data_escala_actual' ); |
| 166 | response[ 'Escala Actual' ] = $escala_actual; |
| 167 | response[ "Data del salt d'escala" ] = timestamp_to_string( $data_escala, 'date' ); |
| 168 | response[ 'Data en segons' ] = $data_escala; |
| 169 | response[ 'Segons transcorreguts des de salt escala' ] = timestamp - $data_escala; |
| 170 | response[ 'Total Aportacions a FOP' ] = $__dada( 'total_FOP_estels' ); |
| 171 | } |
| 172 | }" |
| 173 | } |
| 174 | ] |
| 175 | } |
| 176 | ] |