File tree Expand file tree Collapse file tree 7 files changed +81
-3
lines changed Expand file tree Collapse file tree 7 files changed +81
-3
lines changed Original file line number Diff line number Diff line change @@ -189,5 +189,43 @@ public void GetSemanticDomainUserCountsTestDomMatchesUser()
189189 var result = _statsService . GetSemanticDomainUserCounts ( ProjId ) . Result ;
190190 Assert . That ( result . Find ( uc => uc . Id == user . Id ) ! . WordCount , Is . EqualTo ( wordCount ) ) ;
191191 }
192+
193+ [ Test ]
194+ public void GetSemanticDomainUserCountsTestRecentDomain ( )
195+ {
196+ var user = _userRepo . Create ( GetUserWithProjId ( ) ) . Result ! ;
197+
198+ var olderDomain = new SemanticDomain
199+ {
200+ Id = "1.1.1" ,
201+ Name = "Older Domain" ,
202+ Created = "2023-01-01T10:00:00Z" ,
203+ UserId = user . Id
204+ } ;
205+ var newerDomain = new SemanticDomain
206+ {
207+ Id = "2.2.2" ,
208+ Name = "Newer Domain" ,
209+ Created = "2023-12-31T10:00:00Z" ,
210+ UserId = user . Id
211+ } ;
212+ var anonDomain = new SemanticDomain
213+ {
214+ Id = "3.3.3" ,
215+ Name = "Unknown Domain"
216+ } ;
217+
218+ var word1 = GetWordWithDomain ( ) ;
219+ word1 . Senses [ 0 ] . SemanticDomains = [ anonDomain , newerDomain ] ;
220+ _wordRepo . AddFrontier ( word1 ) ;
221+
222+ var word2 = GetWordWithDomain ( ) ;
223+ word2 . Senses [ 0 ] . SemanticDomains = [ olderDomain ] ;
224+ _wordRepo . AddFrontier ( word2 ) ;
225+
226+ var result = _statsService . GetSemanticDomainUserCounts ( ProjId ) . Result ;
227+ var userCount = result . Find ( uc => uc . Id == user . Id ) ;
228+ Assert . That ( userCount ? . RecentDomain , Is . EqualTo ( newerDomain ) . UsingPropertiesComparer ( ) ) ;
229+ }
192230 }
193231}
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ public class SemanticDomainUserCount
2222 public HashSet < string > DomainSet { get ; set ; }
2323 public int DomainCount { get ; set ; }
2424 public int WordCount { get ; set ; }
25+ public SemanticDomain ? RecentDomain { get ; set ; }
2526
2627 public SemanticDomainUserCount ( )
2728 {
Original file line number Diff line number Diff line change @@ -349,6 +349,18 @@ public async Task<List<SemanticDomainUserCount>> GetSemanticDomainUserCounts(str
349349 }
350350 // update WordCount
351351 domainUserValue . WordCount ++ ;
352+
353+ // update RecentDomain if this domain has a more recent timestamp
354+ if ( ! string . IsNullOrEmpty ( sd . Created ) )
355+ {
356+ if ( domainUserValue . RecentDomain is null ||
357+ sd . Created . ParseModernPastDateTimePermissivelyWithException ( ) . CompareTo (
358+ domainUserValue . RecentDomain . Created
359+ . ParseModernPastDateTimePermissivelyWithException ( ) ) > 0 )
360+ {
361+ domainUserValue . RecentDomain = sd . Clone ( ) ;
362+ }
363+ }
352364 }
353365 }
354366 }
Original file line number Diff line number Diff line change 587587 "domainName" : " Domain Name:" ,
588588 "username" : " Username:" ,
589589 "domainCount" : " Domains:" ,
590+ "recentDomain" : " Most Recent Domain:" ,
590591 "senseCount" : " Words:"
591592 },
592593 "axisLabel" : {
Original file line number Diff line number Diff line change 1212 * Do not edit the class manually.
1313 */
1414
15+ import { SemanticDomain } from "./semantic-domain" ;
16+
1517/**
1618 *
1719 * @export
@@ -48,4 +50,10 @@ export interface SemanticDomainUserCount {
4850 * @memberof SemanticDomainUserCount
4951 */
5052 wordCount ?: number ;
53+ /**
54+ *
55+ * @type {SemanticDomain }
56+ * @memberof SemanticDomainUserCount
57+ */
58+ recentDomain ?: SemanticDomain ;
5159}
Original file line number Diff line number Diff line change 11import { TableCell , Typography } from "@mui/material" ;
2- import { ReactElement } from "react" ;
2+ import { ReactElement , ReactNode } from "react" ;
33import { useTranslation } from "react-i18next" ;
44
55export function HeadCell ( props : { titleId : string } ) : ReactElement {
@@ -12,10 +12,16 @@ export function HeadCell(props: { titleId: string }): ReactElement {
1212 ) ;
1313}
1414
15- export function Cell ( props : { text ?: string | number | null } ) : ReactElement {
15+ interface CellProps {
16+ body ?: ReactNode ;
17+ text ?: string | number | null ;
18+ }
19+
20+ export function Cell ( props : CellProps ) : ReactElement {
21+ const { body, text } = props ;
1622 return (
1723 < TableCell sx = { { borderBottomStyle : "dotted" , borderBottomWidth : 1 } } >
18- < Typography variant = "body1" > { props . text } </ Typography >
24+ { body ? body : < Typography variant = "body1" > { text } </ Typography > }
1925 </ TableCell >
2026 ) ;
2127}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { SemanticDomainUserCount } from "api/models";
1212import { getSemanticDomainUserCount } from "backend" ;
1313import * as LocalStorage from "backend/localStorage" ;
1414import { Cell , HeadCell } from "components/Statistics/TableCells" ;
15+ import DomainChip from "components/WordCard/DomainChip" ;
1516
1617export default function UserStatistics ( ) : ReactElement {
1718 const [ domainUserCountList , setDomainUserCountList ] = useState <
@@ -40,6 +41,7 @@ export default function UserStatistics(): ReactElement {
4041 < TableHead >
4142 < TableRow >
4243 < HeadCell titleId = { "statistics.column.username" } />
44+ < HeadCell titleId = { "statistics.column.recentDomain" } />
4345 < HeadCell titleId = { "statistics.column.domainCount" } />
4446 < HeadCell titleId = { "statistics.column.senseCount" } />
4547 </ TableRow >
@@ -48,6 +50,16 @@ export default function UserStatistics(): ReactElement {
4850 { domainUserCountList . map ( ( t ) => (
4951 < TableRow key = { t . id } >
5052 < Cell text = { t . username } />
53+ < Cell
54+ body = {
55+ t . recentDomain ? (
56+ < DomainChip
57+ domain = { { ...t . recentDomain , userId : undefined } }
58+ provenance
59+ />
60+ ) : null
61+ }
62+ />
5163 < Cell text = { t . domainCount } />
5264 < Cell text = { t . wordCount } />
5365 </ TableRow >
You can’t perform that action at this time.
0 commit comments