| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Consultes'; |
| 6 | |
| 7 | $args = trigger.data; |
| 8 | $_Portal = $args._Portal; |
| 9 | $refcons = $args.refcons; |
| 10 | $refgeto = $args.geto; |
| 11 | $versions = var[ $_Portal ][ 'versions' ] otherwise {}; |
| 12 | $versions_Portal = $versions.Portal otherwise $_Portal; |
| 13 | |
| 14 | $__dada = $refval => { |
| 15 | data_feed[[ oracles = $versions_Portal, feed_name = $refval, ifnone = false ]] |
| 16 | }; |
| 17 | |
| 18 | $versions_Accions = $versions.Accions otherwise $__dada( '_Accions' ); |
| 19 | $__dada_accions = $refval => { |
| 20 | data_feed[[ oracles = $versions_Accions, feed_name = $refval, ifnone = false ]] |
| 21 | }; |
| 22 | |
| 23 | $versions_Getons = $versions.Getons otherwise $__dada( '_Getons' ); |
| 24 | $__dada_getons = $refval => { |
| 25 | data_feed[[ oracles = $versions_Getons, feed_name = $refval, ifnone = false ]] |
| 26 | }; |
| 27 | |
| 28 | $versions_Validacions = $versions.Validacions otherwise $__dada( '_Validacions' ); |
| 29 | $__dada_validacions = $refval => { |
| 30 | data_feed[[ oracles = $versions_Validacions, feed_name = $refval, ifnone = false ]] |
| 31 | }; |
| 32 | |
| 33 | $versions_Validadores = $versions.Validadores otherwise $__dada( '_Validadores' ); |
| 34 | |
| 35 | $Lapse = $__dada( 'Lapse' ); |
| 36 | $cicle_actual = |
| 37 | 1 + floor( ( timestamp - $__dada( 'Origen' ) ) / $__dada( 'Interval' ) ); |
| 38 | }", |
| 39 | "messages": [ |
| 40 | { |
| 41 | "app": "state", |
| 42 | "state": "{ |
| 43 | response[ 'consulta' ] = $refcons; |
| 44 | |
| 45 | if ( $refcons == 'Portal' ) { |
| 46 | |
| 47 | $__resp = $r => { |
| 48 | response[ $r ] = $__dada( $r ); |
| 49 | }; |
| 50 | |
| 51 | $refs_definidors = [ |
| 52 | '_Accions', '_Getons', '_Validacions', '_Validadores', |
| 53 | '_FRO', '_Estels', 'Interval', 'Lapse', |
| 54 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 55 | 'Taxa_Conversio', 'Factor_Conversio', 'Generacio_Minima', |
| 56 | 'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 57 | 'Diposit_Minim', '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' |
| 58 | ]; |
| 59 | |
| 60 | $respon = map( $refs_definidors, 22, $__resp ); |
| 61 | |
| 62 | response[ 'Versions portal' ] = $versions_Portal; |
| 63 | response[ 'Versions Accions' ] = $versions_Accions; |
| 64 | response[ 'Versions Getons' ] = $versions_Getons; |
| 65 | response[ 'Versions Validacions' ] = $versions_Validacions; |
| 66 | response[ 'Versions Validadores' ] = $versions_Validadores; |
| 67 | } |
| 68 | |
| 69 | |
| 70 | if ( $refcons == 'Valor_Dada' ) { |
| 71 | response[ 'Valor ' || $args.ref ] = $__dada( $args.ref ); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | if ( $refcons == 'Darrera_Proposta' ) { |
| 76 | $ordinals = var[ $_Portal ][ 'ordinals' ]; |
| 77 | $id_proposta = $args.ref || '_' || $__dada( 'ordinal_' || $args.ref ); |
| 78 | |
| 79 | if ( $__dada( $id_proposta ) ) { |
| 80 | $temps_prop = $__dada( $id_proposta ); |
| 81 | $data_confirmacio = $temps_prop + $Lapse; |
| 82 | |
| 83 | response[ 'Proposant' ] = $__dada( $id_proposta || '_proposant' ); |
| 84 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 85 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 86 | |
| 87 | $data_validacio = $__dada_validacions( 'validacio_' || $id_proposta ); |
| 88 | if ( is_integer( $data_validacio ) ) { |
| 89 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 90 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 91 | } |
| 92 | } else { |
| 93 | response[ 'No hi ha cap proposta per a aquest param definidor' ] = $id_proposta; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | |
| 98 | if ( $refcons == 'Valor_Proposta' ) { |
| 99 | response[ 'Ref proposta ' || $args.ref ] = $__dada( $args.ref || '_ref' ); |
| 100 | response[ 'Valor proposta ' || $args.ref ] = $__dada( $args.ref || '_val' ); |
| 101 | response[ 'Proposant proposta ' || $args.ref ] = $__dada( $args.ref || '_proposant' ); |
| 102 | $temps_prop = $__dada( $args.ref ); |
| 103 | $data_confirmacio = $temps_prop + $Lapse; |
| 104 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 105 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 106 | |
| 107 | $data_validacio = $__dada_validacions( 'validacio_' || $args.ref ); |
| 108 | if ( is_integer( $data_validacio ) ) { |
| 109 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 110 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | |
| 115 | if ( $refcons == 'Validacio' ) { |
| 116 | $data_validacio = $__dada_validacions( 'validacio_' || $args.idprop ); |
| 117 | response[ 'Proposta' ] = $args.idprop; |
| 118 | if ( is_integer( $data_validacio ) ) { |
| 119 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 120 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | |
| 125 | |
| 126 | if ( $refcons == 'Dades_Node' ) { |
| 127 | $ref_activacio = 'activacio_' || $args.adr || '_en_' || $refgeto; |
| 128 | |
| 129 | $activacio = $__dada_accions( $ref_activacio ); |
| 130 | |
| 131 | if ( $activacio ) { |
| 132 | |
| 133 | $cicle_renovacio = $__dada_accions( 'renovacio_' || $args.adr || '_' || $refgeto ); |
| 134 | |
| 135 | response[ 'Node ' || $args.adr || ' activat per a' ] = $refgeto; |
| 136 | response[ 'Nom node' ] = $__dada_accions( $ref_activacio || '_nom' ); |
| 137 | response[ 'Aportació per activació' ] = $__dada_accions( $ref_activacio || '_qt' ); |
| 138 | response[ 'Cicle activació' ] = $__dada_accions( $ref_activacio || '_cicle' ); |
| 139 | response[ 'Escala activació' ] = $__dada_accions( $ref_activacio || '_escala' ); |
| 140 | response[ 'Data activació' ] = timestamp_to_string( $__dada_accions( $ref_activacio), 'date' ); |
| 141 | |
| 142 | $ref_subscripcio = 'subscripcio_' || $args.adr || '_en_' || $refgeto; |
| 143 | $subscripcio = $__dada_accions( $ref_subscripcio ); |
| 144 | |
| 145 | if ( $subscripcio ) { |
| 146 | response[ 'Subscripció per a ' || $refgeto || ' de' ] = $args.adr; |
| 147 | response[ 'Nom subscripció' ] = $__dada_accions( $ref_subscripcio || '_nom' ); |
| 148 | response[ '% derivació' ] = $__dada_accions( $ref_subscripcio || '_derivacio' ); |
| 149 | response[ 'Cicle subscripció' ] = $__dada_accions( $ref_subscripcio || '_cicle' ); |
| 150 | response[ 'Data subscripció' ] = timestamp_to_string( $__dada_accions( $ref_subscripcio ), 'date' ); |
| 151 | response[ 'Hora subscripció' ] = timestamp_to_string( $__dada_accions( $ref_subscripcio ), 'time' ); |
| 152 | response[ 'Total derivacions' ] = |
| 153 | $__dada( 'total_derivacions_' || $args.adr || '_en_' || $refgeto ); |
| 154 | response[ 'Darrer cicle renovat' ] = |
| 155 | $__dada_accions( 'renovacio_' || $args.adr || '_en_' || $refgeto || '_cicle' ); |
| 156 | } |
| 157 | |
| 158 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 159 | $temps_avis = $__dada_getons( $ref_avis ); |
| 160 | if ( $temps_avis ) { |
| 161 | $avis_es_actual = $temps_avis + ( $Lapse * 2 ) < timestamp; |
| 162 | if ( $avis_es_actual ) { |
| 163 | response[ 'Avís' ] = $__dada_getons( $ref_avis ); |
| 164 | response[ 'Hora' ] = timestamp_to_string( $temps_avis, 'time' ); |
| 165 | response[ 'Data' ] = timestamp_to_string( $temps_avis, 'date' ); |
| 166 | response[ 'Rebot' ] = $__dada_getons( $ref_avis || '_rebot' ); |
| 167 | |
| 168 | } |
| 169 | } |
| 170 | } else { |
| 171 | response[ 'adr ' || $args.adr ] = 'NO activada per a ' || $refgeto; |
| 172 | } |
| 173 | response[ 'Cicle actual' ] = $cicle_actual; |
| 174 | } |
| 175 | |
| 176 | |
| 177 | if ( $refcons == 'Dades_Diposit' ) { |
| 178 | response[ 'Ref' ] = $args.ref; |
| 179 | response[ 'Quantitat dipositada' ] = $__dada_accions( $args.ref ); |
| 180 | response[ 'Dipositant' ] = $__dada_accions( $args.ref || '_dipositant' ); |
| 181 | response[ 'Cicle dipòsit' ] = $__dada_accions( $args.ref || '_cicle' ); |
| 182 | response[ 'Getó dipòsit' ] = $__dada_accions( $args.ref || '_geto_diposit' ); |
| 183 | response[ 'Data dipòsit' ] = $__dada_accions( $args.ref || '_data'); |
| 184 | |
| 185 | response[ 'Taxa' ] = $__dada_accions( $args.ref || '_taxa' ); |
| 186 | response[ 'Qt conversió' ] = $__dada_accions( $args.ref || '_qt_conversio' ); |
| 187 | response[ 'Cicle conversió' ] = $__dada_accions( $args.ref || '_cicle_conversio' ); |
| 188 | } |
| 189 | |
| 190 | |
| 191 | if ( $refcons == 'Dades_Contribucio' ) { |
| 192 | response[ 'Ref' ] = $args.ref; |
| 193 | response[ 'Quantitat' ] = $__dada_accions( $args.ref ); |
| 194 | response[ 'Contribuidora' ] = $__dada_accions( $args.ref || '_contribuidora' ); |
| 195 | response[ 'Cicle contribució' ] = $__dada_accions( $args.ref || '_cicle' ); |
| 196 | response[ 'Escala contribució' ] = $__dada_accions( $args.ref || '_escala' ); |
| 197 | response[ 'Data contribució' ] = $__dada_accions( $args.ref || '_data'); |
| 198 | response[ 'Total Contribucions' ] = $__dada_accions( 'total_contribucions_en_estels' ); |
| 199 | } |
| 200 | |
| 201 | |
| 202 | if ( $refcons == 'Dades_Conversio' OR $refcons == 'Dades_Retribucio' ) { |
| 203 | response[ 'Ref' ] = $args.ref; |
| 204 | response[ 'Receptora' ] = $__dada( $args.ref || '_receptora' ); |
| 205 | response[ 'Quantitat' ] = $__dada( $args.ref || '_qt' ); |
| 206 | response[ 'Data' ] = timestamp_to_string( $__dada( $args.ref ), 'date' ); |
| 207 | if ( $refcons == 'Dades_Conversio' ) |
| 208 | response[ 'Unitat' ] = $__dada( $args.ref || '_unitat' ); |
| 209 | } |
| 210 | |
| 211 | |
| 212 | if ( $refcons == 'Totals' ) { |
| 213 | $total_geto = $__dada_accions( 'total_en_' || $refgeto ); |
| 214 | $total_FOP = $__dada_accions( 'total_FOP_en_' || $refgeto ); |
| 215 | $total_derivacions = $__dada_accions( 'total_derivacions_' || '_en_' || $refgeto ); |
| 216 | $total_activacions = $__dada_accions( 'total_activacions_en_' || $refgeto ); |
| 217 | $total_subscripcions = $__dada_accions( 'total_subscripcions_en_' || $refgeto ); |
| 218 | $total_renovacions = $__dada_accions( 'total_renovacions_en_' || $refgeto ); |
| 219 | $total_diposits = $__dada_accions( 'total_diposits_en_' || $refgeto ); |
| 220 | $total_contribucions = $__dada_accions( 'total_contribucions_en_' || $refgeto ); |
| 221 | |
| 222 | response[ 'Total Getó' ] = $total_geto; |
| 223 | response[ 'Total FOP' ] = $total_FOP; |
| 224 | response[ 'Total Activacions' ] = $total_activacions; |
| 225 | response[ 'Total Subscripcions' ] = $total_subscripcions; |
| 226 | response[ 'Total Renovacions' ] = $total_renovacions; |
| 227 | response[ 'Total Contribucions' ] = $total_contribucions; |
| 228 | response[ 'Total Derivacions' ] = $total_derivacions; |
| 229 | response[ 'Total Diposits' ] = $total_diposits; |
| 230 | } |
| 231 | |
| 232 | |
| 233 | if ( $refcons == 'Cicle_Actual' ) { |
| 234 | response[ 'Cicle actual' ] = $cicle_actual; |
| 235 | response[ 'Data actual' ] = timestamp; |
| 236 | response[ 'Data origen' ] = $__dada( 'Origen' ); |
| 237 | response[ 'Temps transcorregut' ] = timestamp - $__dada( 'Origen' ); |
| 238 | response[ 'Interval definidor' ] = $__dada( 'Interval' ); |
| 239 | } |
| 240 | |
| 241 | |
| 242 | if ( $refcons == 'Escala_Actual' ) { |
| 243 | $escala_actual = $__dada( 'escala_actual' ); |
| 244 | $data_escala = $__dada( 'data_escala_actual' ); |
| 245 | response[ 'Escala Actual' ] = $escala_actual; |
| 246 | response[ "Data del salt d'escala" ] = timestamp_to_string( $data_escala, 'date' ); |
| 247 | response[ 'Data en segons' ] = $data_escala; |
| 248 | response[ 'Total Aportacions a FOP' ] = $__dada( 'total_FOP_en_estels' ); |
| 249 | } |
| 250 | |
| 251 | |
| 252 | if ( $refcons == 'Romanents' ) { |
| 253 | response[ 'Romanent en bytes' ] = balance[ $_Portal ][ base ]; |
| 254 | response[ "Romanent en estels" ] = balance[ $_Portal ][ $__dada( '_Estels' ) ]; |
| 255 | } |
| 256 | }" |
| 257 | } |
| 258 | ] |
| 259 | } |
| 260 | ] |