I have a Location Service
with an endpoint that returns people near from a given user:
GET /users/near?user=7455
[
{
"userId": 1214,
"location" : [2134983, 89384]
},
//more users
]
On the other hand, I have a Visits Service
that manages the visits between users:
[
{
"userVisitor" : 7155,
"userVisited" : 8778,
"date" : "1991/02/10"
}
]
Now, from the API Gateway, I need to fetch users near from a given user and that haven't been visited yet by him. Something like this (pseudocode):
user = 7758
users = LocationService.getNearUsers(user)
output = []
for (userTarget in users) {
if VisitsService.userHasNotVisited(user, userTarget) {
output.add(userTarget)
}
}
return output
Is it a good approach? Or should I implement an endpoint in Visits Service
that filters the non-visited-yet users from a given users list? Something like this:
GET /visits/filter/nonvisited?visitor=7758&targets=1277,3681,3586
and do something like:
user = 7758
users = LocationService.getNearUsers(user)
output = VisitsService.filterNonVisited(user, users)
return output
Which is the better solution?