I am planning to build a dating site. but want some suggestion in getting display users data. In my project, there will be no swipe feature instead we use multiple buttons to send different req. to users.
My Motive for the project is to get the nearest active users first according to interests. All of the modules are done only showing the nearest users algorithm is on hold.
we have to calculate the user's distance from the logged-in user location based on latitude and longitude. Then see the active users who are most close to the logged-in user.
I have stored logged-in users' latitude and longitude in DB.
This is a web project built in laravel-8.
I have to fetch 1 user record at a time after getting the nearest active user.
Note: Main I have to get a solution to get the next user on each click. I have tried it with pagination but that is not a good practice. I need some suggestion to other method to get 1 next user data at a time.
You can checkout inRandomOrder().Seems like it can be handled in one query. Further you can create api to get new user each time.
Try this:
$randomUser = DB::table('users')->whereNotIn('id',$userIdArrayAlreadyShown)->inRandomOrder()->first();
Related
I would like to let users use Google Maps in my store application to find all of my stores along a specified route.
This is the flow I envision:
User creates a starting point and an endpoint for a trip.
User selects a distance from the route that they would be comfortable traveling to get to one of our stores. This would be in miles, say, from 1 to 50 miles.
Given those parameters, Google Maps displays the route along with markers for all stores within those parameters.
User then can click on the stores they want to visit while driving to the destination.
When they are done, my program will generate a list of all the stores they have selected along their route.
A couple of notes:
I have a database of all of our stores that includes city, state, zip, lat, long. It can also contain all of the info that I want returned to the user when the list of stores are selected on the route such as hours, services, etc.
I just need to know if this functionality is possible within the Google Maps api.
I have a REST API built with PHP & MySQL for storing ads.
My database contains an ads table and a users table.
I want to bump the view count for every ad once a user is viewing it (only once, if he views it for the 2nd time, I don't want to raise the count again).
Also, how do I go about setting up a service for the client? Psychologically it seems very aggressive to make a server request each time a user is watching an ad, it could get to hundreds of requests at the same time.
Thanks! :)
So I'm building a music social network in PHP and now I'm stuck at the newsfeed. It should work just as any other newsfeed (Twitter, Facebook ...) and at first point it should be as simple as possible.
I don't have any problem with displaying all the posts from my MySQL database from newest to oldest, but I only want to show posts by users that I follow.
I don't need exact code, just a theoretical explanation how to do it.
I have two MySQL tables - users and posts. Do I need anything else?
Thank you!
Save the user id of the users. Build an API to retrieve the information. Save it into your database and retrieve the info via ajax every minute or so. Simple.
Keep track of which users follow who, then retrieve the posts of the users that the current logged in user is following.
You dont need new tables for this, add a new column in your users table that holds an array of id's of the users you re following. And in your posts table a column which holds the id of the user to who the post belong.
Im using the following Twitter API calls to get the list of people a user follows:
https://dev.twitter.com/docs/api/1/get/users/lookup
https://dev.twitter.com/docs/api/1/get/friends/ids
The idea is to allow the user to send DMs to their friends. Now I have a performance issue ahead of me and I want to see how others have solved it. I have 2 options:
1) Whenever the user logs on, if they have a Twitter account I query the friend list, index alphabetically in an array for easier access and store it in the user's sessions. The problem with his is that it's done every time the user logs on, so if he's following a lot of people it's gonna take a long time, since it can only lookup 100 users at a time, and there's also the rate limit deal. The advantage is it will always have the user list up to date.
2) Do the same when the user associates his Twitter account with my site, and store it in the database, this will make it easier when I have to search the friend list since I can just execute a SELECT query using LIKE and get a matching list to whatever the user is typing, I'm just not sure if this is wise because it would take up a lot of space.
I'm using PHP with CakePHP framework and JQuery. Any other ideas are welcome.
UPDATE:
I decided to go with the DB approach, it takes very lone to query for all the friends so I'd rather do it as little as possible. Now, how would you approach updating this list?
Instead of retrieving the users you could also retrieve the id's only and search the extra information of the users when needed.
Here's an example in jQuery
$.getJSON('http://api.twitter.com/1/friends/ids.json?screen_name=smashingmag&callback=?', function(data) {
$.each(data.ids, function(idx, item) {
console.log('userId: ' + item);
});
});
For more information on the method see: https://dev.twitter.com/docs/api/1/get/friends/ids
I'm working on a small project which will basically do some Facebook stuff and pulls the new daily like for client's pages into my database so I could show them my own charts with their page statistics. Now first of all, I have made a cURL request running with a cron-job and scraping their Total Likes every day using the simple graph-api URL.
The problem is with New Daily Likes / Daily unlikes because, based on my little research, there is no way to access these without having a valid access_token and doing today total - yesterday total is not exactly correct, because it will confuse the new likes with the people who disliked this and it will be a total mess.
I don't want to force my clients to go to Facebook and get an access token to access the insights for 2 reasons: 1) I want it to be totally non-technical so they will not need to mess too much with tokens and stuff outside of my panel. 2) I bet some of them will have problems with storing their access tokens in my database.
How do I do that so they will only need to give me the ID of their page (that's how it currently works and I don't want to change it)?
Basically, there are 2 ways to get Likes information, one is to query public information, like:
http://graph.facebook.com/cocacola
And the other one is to query for page insights information, for which you need access tokens with right permissions.
If you don't want your clients to install your Facebook application with permissions (and with that, give you access token), your only option is to query public information.
As you've noticed, that gives you a problem, since each day "likes" gain is "mashed up" from users adding likes and removing likes, and thus, you dont have precise information about how many users liked and disliked every day. One way would be to query the information, lets say per hour, or even 5 minutes, and store that information. Then, by simple math, you can see how many users liked and disliked the page. It is still not totaly precise, but its alot more valid than "daily information".