• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zooniverse / front-end-monorepo / 14889416145

07 May 2025 05:21PM UTC coverage: 75.291% (-0.3%) from 75.579%
14889416145

push

github

web-flow
Build All Projects page sorted by recently classified (#6854)

* bulid AllProjectsByRecent

* display all projects from /project_preferences in pagination

11220 of 17221 branches covered (65.15%)

Branch coverage included in aggregate %.

31 of 84 new or added lines in 11 files covered. (36.9%)

4 existing lines in 3 files now uncovered.

17401 of 20793 relevant lines covered (83.69%)

386.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.33
/packages/lib-user/src/components/shared/AllProjects/AllProjectsByCount/AllProjectsByCount.js
1
import { useState } from 'react'
1✔
2
import { arrayOf, bool, number, shape, string } from 'prop-types'
1✔
3

4
import { usePanoptesProjects } from '@hooks'
1✔
5
import Projects from '../Projects/Projects.js'
2!
6

7
export const PAGE_SIZE = 49 // 7 cards in each row
1✔
8

9
function AllProjectsByCount({
10
  containerError,
×
11
  containerLoading = false,
×
12
  projectContributions = []
×
13
}) {
14
  const [page, setPage] = useState(1)
×
15

16
  // grab the project ids. They are in order of descending classification count
17
  const projectIds = projectContributions?.map(project => project.project_id)
×
18

19
  const numProjects = projectIds?.length
×
20
  const numPages = Math.ceil(numProjects / PAGE_SIZE)
×
21
  const startSlice = (page - 1) * PAGE_SIZE
×
22
  const endSlice = page < numPages ? page * PAGE_SIZE : numProjects
×
23

24
  // fetch project data from panoptes
25
  const projectsQuery = {
×
26
    cards: true,
27
    id: projectIds?.slice(startSlice, endSlice).join(','),
×
28
    page_size: PAGE_SIZE
29
  }
30

31
  const {
32
    data: projects,
×
33
    error: projectsError,
×
34
    isLoading: projectsLoading
×
35
  } = usePanoptesProjects(projectsQuery)
×
36

37
  // Match project data from panoptes to the stat from ERAS
38
  const renderedProjects = projectContributions
×
39
    ?.map(projectContribution => {
40
      const projectData = projects
×
41
        ?.find(
UNCOV
42
          project => project.id === projectContribution.project_id.toString()
×
43
        )
44
      return {
×
45
        count: projectContribution.count, // for the badge in ProjectCard
46
        ...projectData
47
      }
48
    })
49
    .filter(project => project?.id) // in case a project is not returned from panoptes
×
50

51
  const loading = containerLoading || projectsLoading
×
52
  const error = containerError || projectsError
×
53

54
  return (
×
55
    <Projects
56
      error={error}
57
      loading={loading}
58
      numProjects={numProjects}
59
      page={page}
60
      pageSize={PAGE_SIZE}
61
      renderedProjects={renderedProjects}
62
      setPage={setPage}
63
    />
64
  )
65
}
66

67
AllProjectsByCount.propTypes = {
1✔
68
  containerError: shape({
69
    message: string,
70
    status: number
71
  }),
72
  containerLoading: bool,
73
  projectContributions: arrayOf(
74
    shape({
75
      count: number,
76
      project_id: number
77
    })
78
  )
79
}
1✔
80

81
export default AllProjectsByCount
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc