I have no.of input field to edit by user. when user edits the value I am trying to re-wrap the array. when i do I would like to sort the values in controller. for that i do :
gridView.resort = function( ){
var start = new Date( );
gridView.gridData = $filter( 'orderBy')(slice, "mk", true );
}
when I console the filter I am getting like this:
119
gridData.js:22 879
gridData.js:22 470
gridData.js:22 420
gridData.js:22 392
gridData.js:22 347
gridData.js:22 293
gridData.js:22 234
gridData.js:22 170
gridData.js:22 120
But this is not work for me. when I change the value in one of the field with lesser number it sit on the first row, and it not sorted entire rows. any help?
on page load sortBy works for me :
apiService.generateData( ).then(function( data ){
var start = new Date( );
gridView.gridData = slice = $filter( 'orderBy')(data.splice( 0, 10 ), "mk");
});
Live Demo
(Enter some low values and see the out put )
As commented by #JB Nizet, you should consider using number instead of text.
there is still one way to deal with text which is invoking parseInt at ng-change event, but rememer that this will throw error when some thing else of number when you are typing(means you have to controll what can be typing in).
see the working example.
Related
I am implementing a RPC function for my C application , and try to programmatically declare a queue which limits maximum number of pending messages, after reading the declaration of amqp_table_entry_t and amqp_field_value_t in amqp.h , here's my minimal code sample :
int default_channel_id = 1;
int passive = 0;
int durable = 1;
int exclusive = 0;
int auto_delete = 0;
amqp_table_entry_t *q_arg_n_elms = malloc(sizeof(amqp_table_entry_t));
*q_arg_n_elms = (amqp_table_entry_t) {.key = amqp_cstring_bytes("x-max-length"),
.value = {.kind = AMQP_FIELD_KIND_U32, .value = {.u32 = 234 }}};
amqp_table_t q_arg_table = {.num_entries=1, .entries=q_arg_n_elms};
amqp_queue_declare( conn, default_channel_id, amqp_cstring_bytes("my_queue_123"),
passive, durable, exclusive, auto_delete, q_arg_table );
amqp_rpc_reply_t _reply = amqp_get_rpc_reply(conn);
The code above always returns AMQP_RESPONSE_LIBRARY_EXCEPTION in the object of amqp_rpc_reply_t, with error message a socket error occurred , I don't see any active connection triggered by this code in web management UI of the RabbitMQ. so I think rabbitmq-c library doesn't establish a connection and just reply with error.
However everything works perfectly when I replace the argument q_arg_table with default amqp_empty_table (which means no argument).
Here are my questions :
Where can I find the code which filter the invalid key of the queue argument ? according to this article , x-max-length should be correct argument key for limiting number of messages in a queue , but I cannot figure out why the library still reports error.
Is there any example that demonstrates how to properly set up amqp_table_t passing in amqp_queue_declare(...) ?
Development environment :
RabbitMQ v3.2.4
rabbitmq-c v0.11.0
Appreciate any feedback , thanks for reading.
[Edit]
According to the server log rabbit#myhostname-sasl.log, RabbitMQ broker accepted a new connection, found decode error on receiving frame, then close connection immediately. I haven't figured out the Erlang implementation but the root cause is likely the decoding error on the table argument when declaring the queue.
131 =CRASH REPORT==== 18-May-2022::16:05:46 ===
132 crasher:
133 initial call: rabbit_reader:init/2
134 pid: <0.23706.1>
135 registered_name: []
136 exception error: no function clause matching
137 rabbit_binary_parser:parse_field_value(<<105,0,0,1,44>>) (src/rabbit_binary_parser.erl, line 53)
138 in function rabbit_binary_parser:parse_table/1 (src/rabbit_binary_parser.erl, line 44)
139 in call from rabbit_framing_amqp_0_9_1:decode_method_fields/2 (src/rabbit_framing_amqp_0_9_1.erl, line 791)
140 in call from rabbit_command_assembler:process/2 (src/rabbit_command_assembler.erl, line 85)
141 in call from rabbit_reader:process_frame/3 (src/rabbit_reader.erl, line 688)
142 in call from rabbit_reader:handle_input/3 (src/rabbit_reader.erl, line 738)
143 in call from rabbit_reader:recvloop/2 (src/rabbit_reader.erl, line 292)
144 in call from rabbit_reader:run/1 (src/rabbit_reader.erl, line 273)
145 ancestors: [<0.23704.1>,rabbit_tcp_client_sup,rabbit_sup,<0.145.0>]
146 messages: [{'EXIT',#Port<0.31561>,normal}]
147 links: [<0.23704.1>]
148 dictionary: [{{channel,1},
149 {<0.23720.1>,{method,rabbit_framing_amqp_0_9_1}}},
150 {{ch_pid,<0.23720.1>},{1,#Ref<0.0.20.156836>}}]
151 trap_exit: true
152 status: running
153 heap_size: 2586
154 stack_size: 27
155 reductions: 2849
156 neighbours:
RabbitMQ may not support unsigned integers as table values.
Instead try using a signed 32 or 64-bit number (e.g., .value = {.kind = AMQP_FIELD_KIND_I32, .value = {.i32 = 234 }}).
Also the RabbitMQ server logs may contain additional debugging information that can help understand errors like this as well as the amqp_error_string2 function can be used to translate error-code into an error-string.
hello guys so I am doing a laravel project ( new to laravel ).
i am supposed to to calculation from other tables and save the results in another OUTPUT table.
I have 8 calculation in total in each line and up to 3k lines to fill.
The problem that I get the ma execution time error 60 sec even if a change it in laravel and php.ini.
each function called is just calling a select where and sum I've decided to divide them for better org.
My question is is there a better way to process the data and minimize to exc time if you can help .
public function calcul($week)
{ $test = Output::where('week',$week)->Limit(1);
if($test->first()){
return self::afficher($week);
}
else{
DB::table('article')->orderBy('material')->chunk(100, function ($stocks){
foreach ($stocks as $stock) {
$id = $stock->material;
$safe_stock=self::safe_stock($id);
$past_need=self::PassedNeeds($id) - self::NeedsInTwoWeeks($id);
$two_week_need=self::NeedsInTwoWeeks($id);
$stock_=self::stock($id);
$bdl=self::bdl($id);
$sm=self::sm($id);
$package=self::package($id);
$store_1=self::store_1($id);
$store_2=self::store_2($id);
$store_3=self::store_3($id);
Output::create([
'material' => $id,'safe_stock'=>$safe_stock,'past_need'=>$past_need,'two_week_need'=>$two_week_need,
'stock'=>$stock_,'bdl'=>$bdl,'sm'=>$sm,'package'=>$package,
'store_1'=>$store_1,'store_2'=>$store_2,'store_3'=>$store_3
]);
}
});
return self::index();
}
}
I used this simple script from: https://github.com/icambron/moment-countdown to make a simple countdown. The code below i'm using.
Used Code:
$interval(function(){
$scope.nextDate = moment().countdown($scope.nextDateGet,
countdown.DAYS|countdown.HOURS|countdown.MINUTES|countdown.SECONDS
);
$scope.daysCountdown = moment($scope.nextDate).format('dd');
$scope.hoursCountdown = moment($scope.nextDate).format('hh');
$scope.minutesCountdown = moment($scope.nextDate).format('mm');
$scope.secondsCountdown = moment($scope.nextDate).format('ss');
},1000,0);
This gives correct output
$scope.nextDate.toString();
But this contains one string with the remaining days,hours,minutes and seconds. So i decided i want to split this string into 4 strings by using this:
$scope.daysCountdown = moment($scope.nextDate).format('dd');
$scope.hoursCountdown = moment($scope.nextDate).format('hh');
$scope.minutesCountdown = moment($scope.nextDate).format('mm');
$scope.secondsCountdown = moment($scope.nextDate).format('ss');
Example for input
2016-10-15 10:00:00 // $scope.nextDateGet
Desired output is something like this:
0 // (days)
12 // (hours)
24 // (minutes)
30 // (seconds)
But i can't seem to format the remainings days, i get this output:
Fr // Shortcode for the day the item is scheduled => I need the remaining days in this case that would be 0. The other formatting is correct.
The following output was correct if remaining days was not 0:
$scope.daysCountdown = moment($scope.nextDate).format('D');
If remaining days was 0 it would set remaining days on 14 so this work around did the trick:
if(moment($scope.nextDate).isSame(moment(), 'day')){
$scope.daysCountdown = 0;
} else {
$scope.daysCountdown = moment($scope.nextDate).format('D');
}
Any suggestions to improve this code are always welcome.
I'm try to parse xml file with StAX parser but I face two problems:
First: Two nodes have the same name
Second: read the exactly comment before the values
<database>
<!-- 2015-03-10 01:29:00 EET / 130 --> <row><v> 2.74 </v><v> 1.63 </v></row>
<!-- 2015-03-10 01:30:00 EET / 170 --> <row><v> 5.33 </v><v> 1.68 </v></row>
<!-- 2015-03-10 01:31:00 EET / 180 --> <row><v> 7.62 </v><v> 1.83 </v></row>
<database>
I want to collect the data like that:
Date:2015-03-10 01:29:00
V1: 2.74
V2:1.63
I was using Dom parser before and it was so easy to deal with dublicate node name and comments unfortunately I have to use StAX now and I don't know how to solve those problems :(
The first issue: two nodes have the same name
<v> 2.74 </v><v> 1.63 </v>
There is no issue with StAX, if you follow the events you will get in order:
startElement ( v )
characters ( 2.74 )
endElement ( v )
startElement ( v )
characters ( 1.63 )
endElement ( v )
So it is up to you to handle minimal of context information in your code to know if it is the first or the second time you are starting a <v> element.
The second issue: read the comments
There is no issue neither, the StAX parsing triggers events for comments as well, you can simply get the comment as String with the API and extract yourself the expected value, for instance:
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(inputStream);
while (streamReader.hasNext()) {
int event = streamReader.next();
if(event == XMLStreamConstants.COMMENT) {
String aDateStringVal = streamReader.getText();
// + extract your date value from the comment string
}
}
i have a table
Fields
class 1
class 2
class 3
class 4
a1
10
240
340
401
a2
12
270
340
405
a3
12
270
340
405
a4
15
270
360
405
a5
17
720
530
450
i have this in grid as well as in Json.store , what i have to do is perform mathematical calculation each time the grid is refreshed by "table name".reconfigure(..... , ....)
consider the column "class1" ,
value(a5) = ( value(a1)+ 2*value(a2) + 3*value(a3) ) /value(a4)
can anybody please help he on this problem ,
I will be very very Thankful for help :)
As I'm not sure what aspect of the problem you are having difficulty with, I'll address both at a high level.
Generally speaking you want to have your reconfigure method update the Ext Store, which will then trigger an event that the Grid should handle. Basically, change the Store and your Grid will be updated automatically.
As far as generating the correct new row... it seems fairly straightforward - a rough pass:
/*for each field foo_X through foo_N:*/
var lastElementIndex = store.data.size-1;
var total = 0;
for (var i=0; i<; i++) {
if (i != lastElementIndex) {
total += store.data[i].get(foo_X)*i;
} else {
total = total/store.data[i].get(foo_x);
}
}
/*construct your json object with the field foo*/
/*after looping through all your fields, create your record and add it to the Store*/