I facing a huge problem here i have a zf apigility as my backend and a simple dropdown in my front-end, and i want to get all the results of REST in apigility URL and put as autocomplete in my dropdown, but my problem is that i have about 72,000 register in database :/ some advices ?
thanks
Two concepts you need to include in your autocomplete endpoint.
Filtering and Pagination.
First and foremost, I'd decide on a sensible minimum number of characters before returning results. 2? 3? Whatever works for you.
Secondly, don't return EVERY result, return only the first page (page size is up to you, 20? 50? however many is acceptable to you).
Related
Stack: Flask, Postgres and thousands of records. The "Flask-Pagination" library works great, looks cool, and lots of options. But documentation is not there. Once I do a "search" the pagination will not pass the search query back to Flask. And I crash.
Looking at the documentation, there must be a way to access and pass the search terms, but I'm not seeing it, and zero examples on line.
List of library attributes here: https://flask-paginate.readthedocs.io/en/master/
Example here. Search for Brain, you will get over 400+ responses but cannot get pass the first page if you want to pagination, 96 records at a time. Do a "Update" all and you can pagination through thousands of records.
Live example: https://www.hackingthevirus.com
Thanks, LOTS!
Used sessions. Allows for saving of the "search" value across multiple pages.
What are the options in a web api to indicate that the returned data is paged and there is further data available.
ASP.Net Web API with OData uses a syntax similar to the following:
{
"odata.metadata":"http://myapi.com/api/$metadata#MyResource","value":[
{
"ID":1,"Name":"foo"
},
...
{
"ID":100,"Name":"bar"
}
],"odata.nextLink":"http://myapi.com/api/MyResource?$skip=20"
}
Are there any other ways to indicate the link to the next/previous 'page' of data without using a metadata wrapper around the results. Can this be achieved by using custom response headers instead?
Let's take a step back and think about WebAPI. WebAPI in essence is a raw data delivery mechanism. It's great for making an API and it elevates separation of concerns to a pretty good height (specifically eliminating UI concerns).
Using Web API, however, doesn't really change core of the issue you are facing. You're asking "how do I want to query my data store in an performant manner and return the data to the client efficiently?" Your decisions here really parallel the same question when building a more traditional web app.
As you noted, oData is one method to return this information. The benefit here is it's well known and well defined. The body of questions/blogs/articles on the topic is growing rapidly. The wrapper doesn't add any meaningful overhead.
Yet, oData is by no means the only way you can do this. We've had to cope with this since software has been displaying search results. It's tough to give you specific advice without really understanding your scenario. Here are some questions that bubbled up as I read your question :
Are your results sets huge but users only see the first one or two
pages?
Or do user tend to page through all of the results?
Are pages of results limited (like 20 or 50 per page) or 100's/ 1000's ?
Does the data set shift rapidly, so records are added as the user is
paging?
Are your result sets short and adding columns that repeat tolerable?
Do you have enough control over the client do do something out of band -- like custom HTTP headers, or a separate HTTP request that just asks for a query summary?
There really are hundreds of options depending on your needs. I don't know what you're using as a data store, but I wrote a post on getting row count efficiently. The issues there are very germane here, albeit from the DB perspective. It might help you get some perspective.
I am building a web app that pulls data through the Core Reporting Api v3 from Google. I am using the client PHP library offered by Google.
I am currently trying to specify a page and retrieve its pageviews for a time range. Every other seems to be working okay except for the fact that if a specfy a filter with ga:pagePath==http://link/uri then I get 0 all the time no matter the time range.
I think the problem is got to do with the setting of value for this pagePath. I want to have spearate data for the desktop version of the site and the smartphone version denoted by s. subdomain
Can anyone hint me on some tips and or tricks to use to get the required data?
Example URL:
http://domain.com/user/profile/id/1
http://s.domain.com/user/profile/id/1
Thanks in advance!
for the the default implementation of Google Analytics, ga:pagePath doesn't include the scheme or hostname so in your case you'd actually want to filter using ga:hostname and ga:pagePath together.
I suggest you use the Query Explorer to build your queries and get familiar with what will work. You can also use this tool to at least get a sense for what type of data the ga:pagePath and ga:hostname dimensions return before trying to filter on them. Finally, once you have the query you want, you can easily get the exact Core Reporting API query by clicking on the Query URI button.
Also check out the Combining Filters section of GA API docs.
So if you want filter on ga:pagepath for domain.com and s.domain.com separately you could do something like
filters=ga:pagePath==/user/profile/id/1;ga:hostname==domain.com
filters=ga:pagePath==/user/profile/id/1;ga:hostname==s.domain.com
I have a pretty complex registration form.. it has about 40 fields (go ahead and laugh, the client wants it that way, argh).
Some of the fields are hidden/shown based on the value of other fields.
The problem with using Drupal built in "required" field is that fields that are not displayed are still tagged as required. Reason being the Drupal validation is done server side.
I need to do client side validation because of the way some fields are hidden/shown.
Is this even possible? If so, how should I go about doing it?
Yes it is possible, there is an #ajax property you can use for this, you are going to have to go quite deep into the form api to achieve this.
http://drupal.org/node/1043838
This not going to be easy, it is one of the most challenging aspects. I think a bit of training would help
I would look at maybe getting a membership for a month to drupalize me or https://buildamodule.com
I have only used Druplaize me as it has more d6 stuff but buildamodule.com is very well priced at $29usd a month. Good luck!
I think this describes the use of the new feature #state in the FAPI. You can read about that here: http://api.drupal.org/api/examples/form_example%21form_example_states.inc/function/form_example_states_form/7
You can have a look at the clientside_validation module, it can handle 'hidden' fields. But normally Drupal validate should respect the #required in combination with #states.
I did not realise the power of REST until I started using scaffolds in rails. This makes life so simple. Now everytime I try to develop a web application I only think of those 6 verbs. But I have a doubt. How is search related to REST.
Basically the search page which contain a form for the user to input a search term.
which verb does this come under? Is it list??
and what does the search results come under? show?
Search is GET on the collection with some fancy attributes:
GET /articles?q=RESFful+Architecture&in_title=1
Something like that.
There are plenty of resources on the subject, check out Handling arbitrary actions, on ajaxpatterns, for example.
If I understand what you are saying properly, the search page wouldn't be a part of the rest service, but would submit to it.
The search results would be a list of whatever the first class object you had defined was. The Uri would describe the resource that was being displayed.
Retrieving resources is always done with a GET
eg: GET /cars?term=hyundai+green