Skip to content

Commit 0f8a455

Browse files
authored
Merge pull request #978 from mapswipe/dev
Release - 2024 October
2 parents 62310b0 + 7485e42 commit 0f8a455

File tree

23 files changed

+152
-33
lines changed

23 files changed

+152
-33
lines changed

community-dashboard/app/components/ContributionHeatMap/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ function HeatmapComponent(props: HeatmapComponentProps) {
5050
const map = useMap();
5151

5252
useEffect(() => {
53-
map.gestureHandling.enable();
53+
// NOTE: We need to cast type of map here because of how gesture handle plugin works
54+
type MapWithGestureHandle = typeof map & { gestureHandling: { enable: () => void }};
55+
(map as MapWithGestureHandle).gestureHandling.enable();
5456
}, [map]);
5557

5658
useEffect(() => {

community-dashboard/app/components/ItemSelectInput/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
IoPeople,
77
IoSearch,
88
} from 'react-icons/io5';
9-
import { _cs } from '@togglecorp/fujs';
9+
import { isFalsyString, _cs } from '@togglecorp/fujs';
1010
import {
1111
useQuery,
1212
gql,
@@ -192,7 +192,7 @@ function ItemSelectInput<Name extends string>(props: ItemSelectInputProps<Name>)
192192
() => ([
193193
...(usersData?.map((user) => ({
194194
id: user.userId,
195-
name: user.username ?? 'Unknown',
195+
name: (isFalsyString(user.username) ? user.userId : user.username),
196196
type: 'user' as const,
197197
})) ?? []),
198198
...(userGroupsData?.map((userGroup) => ({

community-dashboard/app/components/MemberItem/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { Link, generatePath } from 'react-router-dom';
3-
import { isDefined } from '@togglecorp/fujs';
3+
import { isDefined, isFalsyString } from '@togglecorp/fujs';
44

55
import NumberOutput from '#components/NumberOutput';
66
import routes from '#base/configs/routes';
@@ -13,7 +13,7 @@ interface Props {
1313
totalMappingProjects: number;
1414
totalSwipeTime: number;
1515
totalSwipes: number;
16-
username: string;
16+
username?: string | null;
1717
userId: string;
1818
isActive: boolean;
1919
};
@@ -27,14 +27,17 @@ function MemberItem(props: Props) {
2727
{ userId: member.userId },
2828
);
2929

30+
// NOTE: OSM user does not have username stored
31+
const memberName = isFalsyString(member.username) ? member.userId : member.username;
32+
3033
return (
3134
<div className={styles.member}>
3235
<div className={styles.memberName}>
3336
<Link
3437
className={styles.link}
3538
to={path}
3639
>
37-
{member.username}
40+
{memberName}
3841
</Link>
3942
{!member.isActive && (
4043
<div className={styles.inactive}>

community-dashboard/app/components/SelectInput/SearchSelectInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function SearchSelectInput<
231231
);
232232

233233
const optionRendererParamsDefault = useCallback(
234-
(key: T, option: O) => {
234+
(key: T, option: O): P => {
235235
const isActive = key === value;
236236

237237
return {

community-dashboard/app/views/UserDashboard/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from 'react';
1+
import React, { useMemo } from 'react';
22
import { gql, useQuery } from '@apollo/client';
3-
import { encodeDate } from '@togglecorp/fujs';
3+
import { encodeDate, isDefined, isFalsyString } from '@togglecorp/fujs';
44
import { useParams, generatePath, Link } from 'react-router-dom';
55

66
import useUrlState from '#hooks/useUrlState';
@@ -181,11 +181,22 @@ function UserDashboard(props: Props) {
181181

182182
const filteredStats = filteredUserStats?.userStats?.filteredStats;
183183

184+
// NOTE: OSM user does not have username stored
185+
const userName = useMemo(() => {
186+
if (isDefined(userStats) && isDefined(userStats.user)) {
187+
return isFalsyString(userStats.user.username)
188+
? userStats.user.userId
189+
: userStats.user.username;
190+
}
191+
192+
return null;
193+
}, [userStats]);
194+
184195
return (
185196
<Page
186197
className={className}
187198
variant="user"
188-
heading={userStats?.user.username}
199+
heading={userName}
189200
totalSwipes={totalSwipes}
190201
totalSwipesLastMonth={totalSwipesLastMonth}
191202
totalTimeSpent={totalSwipeTime}

community-dashboard/app/views/UserGroupDashboard/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useCallback, useMemo, useState } from 'react';
22
import { gql, useQuery, useLazyQuery } from '@apollo/client';
3-
import { encodeDate } from '@togglecorp/fujs';
3+
import { encodeDate, isFalsyString } from '@togglecorp/fujs';
44
import { useParams } from 'react-router-dom';
55

66
import StatsBoard from '#views/StatsBoard';
@@ -137,7 +137,7 @@ const USER_MEMBERSHIPS_EXPORT = gql`
137137
type UserGroupMember = NonNullable<NonNullable<NonNullable<UserGroupStatsQuery['userGroup']>['userMemberships']>['items']>[number];
138138

139139
function memberKeySelector(member: UserGroupMember) {
140-
return member.username;
140+
return member.userId;
141141
}
142142

143143
interface DateRangeValue {
@@ -239,7 +239,7 @@ function UserGroupDashboard(props: Props) {
239239
['User', 'Total swipes', 'Project contributed', 'Time spent(mins)'],
240240
...(newUserMembershipsData?.map((user) => (
241241
[
242-
user.username,
242+
isFalsyString(user.username) ? user.userId : user.username,
243243
user.totalSwipes,
244244
user.totalMappingProjects,
245245
user.totalSwipeTime,

django/apps/existing_database/migrations/0002_mappingsession_mappingsessionresult.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class Migration(migrations.Migration):
2222
("start_time", models.DateTimeField(blank=True, null=True)),
2323
("end_time", models.DateTimeField(blank=True, null=True)),
2424
("items_count", models.SmallIntegerField(default=0)),
25+
("app_version", models.CharField(max_length=999)),
26+
("client_type", models.CharField(max_length=999)),
2527
],
2628
options={
2729
"db_table": "mapping_sessions",

django/apps/existing_database/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ class MappingSession(Model):
233233
start_time = models.DateTimeField(blank=True, null=True)
234234
end_time = models.DateTimeField(blank=True, null=True)
235235
items_count = models.SmallIntegerField(null=False, default=0)
236+
app_version = models.CharField(max_length=999)
237+
client_type = models.CharField(max_length=999)
236238

237239
class Meta:
238240
managed = False

django/apps/existing_database/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class UserGroupLatestStatsType:
7171
@strawberry.type
7272
class UserGroupUserStatsType:
7373
user_id: str
74-
username: str
74+
username: str | None
7575
total_mapping_projects: int
7676
total_swipes: int
7777
total_swipe_time: TimeInSeconds
@@ -545,7 +545,7 @@ async def id(self, info: Info, root: UserGroup) -> strawberry.ID:
545545
class UserGroupUserMembershipType:
546546
id: strawberry.ID
547547
user_id: str
548-
username: str
548+
username: str | None
549549
is_active: bool
550550
# Stats
551551
total_mapping_projects: int

django/schema.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ type UserGroupTypeCountList {
225225
type UserGroupUserMembershipType {
226226
id: ID!
227227
userId: String!
228-
username: String!
228+
username: String
229229
isActive: Boolean!
230230
totalMappingProjects: Int!
231231
totalSwipes: Int!
@@ -241,7 +241,7 @@ type UserGroupUserMembershipTypeCountList {
241241

242242
type UserGroupUserStatsType {
243243
userId: String!
244-
username: String!
244+
username: String
245245
totalMappingProjects: Int!
246246
totalSwipes: Int!
247247
totalSwipeTime: TimeInSeconds!

0 commit comments

Comments
 (0)