diff --git a/app/src/screens/communities/ListGroupScreen.tsx b/app/src/screens/communities/ListGroupScreen.tsx index f7afe21e..30ad9c2e 100644 --- a/app/src/screens/communities/ListGroupScreen.tsx +++ b/app/src/screens/communities/ListGroupScreen.tsx @@ -8,7 +8,7 @@ import { AppPressableIcon } from "@/components/base/AppPressable"; import { AppIcon } from "@/components/base/AppIcon"; import { AppColors, ContextualColors } from "@/theme/colors"; import { extractDays } from "@/util/hooks/days"; -import { CoMatch, MatchGroup, RallyingPoint } from "@liane/common"; +import { CoMatch, MatchGroup } from "@liane/common"; import { extractWaypointFromTo } from "@/util/hooks/lianeRequest"; export const ListGroupScreen = () => { @@ -18,31 +18,12 @@ export const ListGroupScreen = () => { const insets = useSafeAreaInsets(); const [error, setError] = useState(undefined); - const { to, from, steps } = useMemo(() => extractWaypointFromTo(lianeRequest?.wayPoints), [lianeRequest.wayPoints]); + const { to, from } = useMemo(() => extractWaypointFromTo(lianeRequest?.wayPoints), [lianeRequest.wayPoints]); const daysReccurence = extractDays(lianeRequest.weekDays); const localeTime = lianeRequest?.timeConstraints[0] ? `${lianeRequest?.timeConstraints[0]?.when?.start?.hour}h${lianeRequest?.timeConstraints[0]?.when?.start?.minute}` : ""; - const GroupItem = ({ group }: { group: CoMatch }) => ( - navigation.navigate("CommunitiesChat", { group: group, request: lianeRequest })}> - - - - {`${group.pickup.label} ➔ ${group.deposit.label}`} - {`${extractDays(group.weekDays)}`} - {`${(group as MatchGroup).matches?.length ?? 1} membre${ - (group as MatchGroup).matches?.length > 1 ? "s" : "" - }`} - - - - - - - - ); - return ( {error && ( @@ -76,12 +57,41 @@ export const ListGroupScreen = () => { - } /> + ( + navigation.navigate("CommunitiesChat", { group: item, request: lianeRequest })} /> + )} + /> ); }; +type GroupItemProps = { + group: CoMatch; + onPress: () => void; +}; + +const GroupItem = ({ group, onPress }: GroupItemProps) => ( + + + + + {`${group.pickup.label} ➔ ${group.deposit.label}`} + {`${extractDays(group.weekDays)}`} + {`${(group as MatchGroup).matches?.length ?? 1} membre${ + (group as MatchGroup).matches?.length > 1 ? "s" : "" + }`} + + + + + + + +); + const styles = StyleSheet.create({ mainContainer: { backgroundColor: AppColors.lightGrayBackground, diff --git a/app/yarn.lock b/app/yarn.lock index f290ef5e..2a60bbc2 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -7713,11 +7713,16 @@ tslib@^1.8.1: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0, tslib@^2.6.2: +tslib@^2.0.1, tslib@^2.0.3, tslib@^2.4.0: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== +tslib@^2.1.0, tslib@^2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" + integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" diff --git a/back/src/Liane/Liane.Service/Internal/Community/LianeMatcher.cs b/back/src/Liane/Liane.Service/Internal/Community/LianeMatcher.cs index cb4b5667..b22f1902 100644 --- a/back/src/Liane/Liane.Service/Internal/Community/LianeMatcher.cs +++ b/back/src/Liane/Liane.Service/Internal/Community/LianeMatcher.cs @@ -51,38 +51,35 @@ public async Task> FindMatches( private static async Task> FindRawMatches(IDbConnection connection, IEnumerable lianeRequests, IDbTransaction? tx = null) { return await connection.QueryAsync(""" - SELECT liane_request_a.id AS "from", - liane_request_b.id AS liane_request, - liane_request_b.name AS name, - liane_request_b.created_by AS "user", - liane_request_b.way_points AS way_points, - liane_request_b.is_enabled AS is_enabled, - st_length(intersection) / a_length AS score, - matching_weekdays(liane_request_a.week_days, liane_request_b.week_days) AS week_days, - st_startpoint(intersection) AS pickup, - st_endpoint(intersection) AS deposit, - nearest_rp(st_startpoint(intersection)) AS pickup_point, - nearest_rp(st_endpoint(intersection)) AS deposit_point, - (SELECT array_agg(liane_id) FROM liane_member WHERE liane_request_id = liane_request_b.id) AS lianes - FROM ( - SELECT a.way_points AS a, - b.way_points AS b, - st_linemerge(st_intersection(a.geometry, b.geometry)) intersection, - st_length(a.geometry) AS a_length - FROM route a - INNER JOIN route b ON st_intersects(a.geometry, b.geometry) - ) AS matches - INNER JOIN liane_request liane_request_a ON - liane_request_a.way_points = a - INNER JOIN liane_request liane_request_b ON - liane_request_b.way_points = b AND liane_request_b.created_by != liane_request_a.created_by - LEFT JOIN liane_member ON - liane_request_id = liane_request_b.id - WHERE - matching_weekdays(liane_request_a.week_days, liane_request_b.week_days)::integer != 0 - AND st_length(intersection) / a_length > 0.3 - AND liane_request_a.id = ANY(@liane_requests) - ORDER BY st_length(intersection) / a_length DESC, liane_request_a.id + SELECT liane_request_match.id AS "from", + liane_request_b.id AS liane_request, + liane_request_b.name AS name, + liane_request_b.created_by AS "user", + liane_request_b.way_points AS way_points, + liane_request_b.is_enabled AS is_enabled, + st_length(intersection) / a_length AS score, + matching_weekdays(liane_request_match.week_days, liane_request_b.week_days) AS week_days, + st_startpoint(intersection) AS pickup, + st_endpoint(intersection) AS deposit, + nearest_rp(st_startpoint(intersection)) AS pickup_point, + nearest_rp(st_endpoint(intersection)) AS deposit_point, + (SELECT array_agg(DISTINCT liane_id) FROM liane_member WHERE liane_request_id = liane_request_b.id) AS lianes + FROM (SELECT liane_request.id, + liane_request.created_by, + liane_request.week_days, + a.way_points AS a, + b.way_points AS b, + st_linemerge(st_intersection(a.geometry, b.geometry)) intersection, + st_length(a.geometry) AS a_length + FROM liane_request + INNER JOIN route a ON a.way_points = liane_request.way_points + INNER JOIN route b ON st_intersects(a.geometry, b.geometry) + WHERE liane_request.id = ANY(@liane_requests)) AS liane_request_match + INNER JOIN liane_request liane_request_b ON + liane_request_b.way_points = b AND liane_request_b.created_by != liane_request_match.created_by + WHERE matching_weekdays(liane_request_match.week_days, liane_request_b.week_days)::integer != 0 + AND st_length(intersection) / a_length > 0.3 + ORDER BY st_length(intersection) / a_length DESC, "from" """, new { liane_requests = lianeRequests.ToArray() }, tx @@ -125,6 +122,7 @@ private async Task> GroupMatchByLiane(IEnumerable m.Score) .ThenByDescending(m => m switch {