Storing and retrieving a large list in Ionic 2+ - list

I aim to use the native storage plugin to store a potentially large list of objects in Ionic 3. I want to be able to then display the list in an Ionic infinite scrolling list. I presume that if I save the entire list to storage as a single object, with a single key, it will take quite some time to retrieve it, and the list page will remain empty for some time while the list is read asynchronously from storage.
Should I be saving each item in the list with an individual key, such as "key.1", "key.2", "key.3" etc, and then retrieving a "pageful" of items at a time, supported by the infinite scrolling list? The nuisance part of this is that when I want to add a new item to the list, I have to know what key number I'm up to, so I can generate the next key name.
What's the best practice for this scenario? Is there a better way to load a large list from memory asynchronously so that it can be displayed to the user as soon as possible?

I ended up storing my items in a table in a SQLite database, as I wanted to avoid the size limitations that local storage can impose. I use a query like SELECT * FROM submissions LIMIT ? OFFSET ? to fetch a pageful of items at a time from the doInfinite function of an Ionic infinite scroller, keeping track of what page I'm up to and passing that into the OFFSET parameter. The LIMIT argument is the number of rows to fetch for a page, e.g. 10.

Related

Pagination in DynamoDB list of items

I am having a list of items, can i implement pagination on location attribute e.g fetch from indexes 0 to 10, 10 to 20...
{
continent:String,
country:String,
locations:[ {address,phone},{address,phone}....]
}
The DynamoDB read requests (e.g., GetItem) have a ProjectionExpression option where you can pass a list of attributes as well as sub-attributes you want to fetch from the item instead of the whole item. So you can use
ProjectionExpression="locations[10],locations[11],...,locations[19]"
to have GetItem return just elements 10..19 from the "locations" list. Unfortunately there is no shorter syntax to get a range of indices.
However, you should be aware that even if you ask to only read elements 10..19 from the list, you'll actually be paying to read the entire item. DynamoDB assumes that items (the whole thing in your example) are fairly small (the hard limit is 400 KB), and any read or write to an item - even if just to a part of it - incurs a cost proportional to the length of the entire item. So although you could do paging using the syntax I just described, it not usually not a cost-effective approach. If you read an item in 20 "pages", you'll be paying for reading the same item 20 times! You're better off just fetching the entire item (again, it's limited in size anyway) once and paging through it in the client.
When talking about paging being an effective approach, the discussion is usual about multiple items in the same partition, i.e., multiple items with the same hash key and different sort key. You can then page through these items using the Query request, and you will be paying just for the items you paged through. With such approach the length of the "list" (it's not really a list, but rather many separate items) is practically unbounded.

Flex 3 MX List: need to programmatically reorder the list's item renderers

Ok, I have to use Flex 3 because I am using this in an Adobe Connect pod. I have a List component, which is capable of being reordered through drag and drop. If someone leaves the browser and comes back into the meeting room, I am trying to redisplay how they had items ordered from their drag and drop. So I need a way to reorder the list. I was looking into sort for Arrays on the dataProvider. But I have not been able to figure out the proper event to sort the list once, all of the items have the appropriate data in.
In any case, does anyone know how to tell the data of an itemRenderer to have ordered values, and then tell the list to reorder the items in the list according to the new values?
One of the possible ways I used:
Keep your data in Object(map) with key:value, Object{rowIndex:rowData}
e.g. {1 : row1Data,
2 : row2Data, ... }
Prepare the list values based on the keys and then assign it to the grid. This way, Itemrenderer will no longer need to know the "order" of the data. Their task is just to display the data.
Once user is done with drag-drop - update the map, persist it.
Hope this helps.
If you use an ArrayCollection, you can apply a sort, and then call arrayCollection.refersh() to refresh the collections with the sort, which will then update the list display

Looping through data over multiple pages in Django

I'm trying to find the best way to go about my problem and I would love your input. I am trying to allow users to scan multiple barcodes into a text area. After they are submitted they are split into an array. The user then inputs how many iterations of each value in the array are to be inserted into a MySQL database. I've achieved this using PHP and session variables, looping through the array one step at a time. With Django I've found it a little more difficult and I am wondering if I should just have a "temporary" table in my database that gets refilled with the values from the array of barcodes. The following pages then pull each value from the table instead of using any sort of session variables.
Edit:
I apologize for the confusing question. Let me try and clear it up a bit:
I need to render a view based on each value in the user-submitted array. When it is first submitted, a view is rendered for the first value. When the user hits "Next" a view will be rendered for the second value in the array, and so on.
As for the database issue, each value can have two "types." The user will declare how many of each type is added to the database in each of the views I am trying to render.
Thank you.
this is nothing about django.
forget that temporary table.
add a field "filled" to ur table
select 1st not-filled row, and show "refill" page by this row
then update user input number back to db, set "filled" to "true" at same time.
You probably can port your PHP solution using a Django session object.
I'm not sure if that "one item at a time" is a feature or a "it was easier to code that way" thing, but in the second case - you may want to use Django Formsets to display all items at once and avoid looping through the array.

Flex4.6 Add element to top of List

I've got a spark list that gets dynamically filled.
So far the new items appear at the bottom of the list. What I'd like to do is to add them at the top.
The items in the list have a unique ID so some kind of sorting mechanism would probably do the trick as the new items have a greater ID than the old ones.
What I'd like to avoid is some complex method behind this as I'm working on a mobile platform and the list can get quite big so I need this to be as efficient as possible.
The list's data provider is an ArrayList that gets updated using binding.
How can that be done?
Thanks in advance!
u can Add the items at the starting index of the datagrid. Flex datagrid automatically renew all the indexes and add 1 to all existing element indexes. So
YourDataGridId.dataprovider.addItemAt(item,0) will do.

In memcached, you can put a List as a value. Can you put a list in beanstalkd?

Actually, I would like to use this for logging.
I want to put a dictionary into beanstalkd.
Everytime someone goes into my website, I want to put a dictionary into beanstalkd, and then every night, I want a script that will get all the jobs and stick them in the database.
THis will make it fast and easy.
You can have a large upper limit on the size of each job in beanstalk (>2MB) but performance does seem to be adversely affected at that point. If the size of the dictionary is large you probably want to store the actual dictionary in a SQL table and store the ID of that row in the job, then have the worker retrieve the SQL row when it grabs the job that has the correlated ID.