Skip to content
Snippets Groups Projects
Commit 033d9109 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

TandemPlugin: Further improvement of the matching SQL query

git-svn-id: https://server2.data-quest.de/svn/studip-plugins/TandemPlugin@2471 6a1f69d7-6018-4d13-bf90-b098e98c258d
parent c12e90c7
No related branches found
No related tags found
No related merge requests found
......@@ -76,21 +76,30 @@ class TandemMatching
//
// SELECT request_profile_id FROM tandem_pairs WHERE status > '-1'
// AND request_profile_id = :profile_id:
// The pair must be requested (0) or established (1) and
// the profile-ID of the profile we're searching matches for
// The profile-ID of the profile we're searching matches for
// must match either the request_profile_id or the
// offer_profile_id. The latter filters out all requests
// and established pairs that have been made with that profile.
//
// SELECT offer_profile_id FROM tandem_pairs WHERE status > '-1'
// SELECT offer_profile_id FROM tandem_pairs WHERE status > '-1':
// The same as with request_profile_id but here we're selecting
// the offer_profile_ids and use them in a UNION.
//
// SELECT request_profile_id FROM tandem_pairs WHERE status = '1'
// and
// SELECT offer_profile_id FROM tandem_pairs WHERE status = '1':
// We select the request_profile_ids and offer_profile_ids
// of all established pairs.
// )
$sql .= "AND tandem_profiles.id NOT IN (
SELECT request_profile_id FROM tandem_pairs WHERE status > '-1' AND (request_profile_id = :profile_id OR offer_profile_id = :profile_id)
SELECT request_profile_id FROM tandem_pairs WHERE request_profile_id = :profile_id OR offer_profile_id = :profile_id
UNION
SELECT offer_profile_id FROM tandem_pairs WHERE offer_profile_id = :profile_id OR request_profile_id = :profile_id
UNION
SELECT request_profile_id FROM tandem_pairs WHERE status = '1'
UNION
SELECT offer_profile_id FROM tandem_pairs WHERE status > '-1' AND (offer_profile_id = :profile_id OR request_profile_id = :profile_id)
SELECT offer_profile_id FROM tandem_pairs WHERE status = '1'
) ";
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment