Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#17] Add contributors support #57

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/components/GridItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ export default ({
return (
<Box className={classes.root}>
<Card className={classes.card} elevation={0} component="a">
<CardMedia
className={classes.cover}
image={image}
title={title}
/>
{
!!image
&&
<CardMedia
className={classes.cover}
image={image}
title={title}
/>
}
<span className={classes.details}>
<CardContent className={classes.content}>
<Typography component="h5" variant="h5">
Expand Down
10 changes: 10 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const GSHEET_SHEET_TASKFORSES = 2
export const GSHEET_SHEET_MEMBERS = 3
export const GSHEET_SHEET_MINUTES = 4
export const GSHEET_SHEET_RESOURCES = 5
export const GSHEET_SHEET_CONTRIBUTIONS = 6
export const GSHEET_MULTIFIELDS_SEPARATOR = `;`

const getGSheetUrl = sheet => `/${sheet}/${GSHEET_SUFFIX}`
Expand Down Expand Up @@ -228,6 +229,15 @@ export function getResourcesByTaskForseSync(id, resources) {
) : []
}

export async function getContributions() {
return normalizeGSheetJSON(await api.get(getGSheetUrl(GSHEET_SHEET_CONTRIBUTIONS)))
}

export async function getContributors() {
const contributions = filter(await getContributions(), c => !!c["Autore"])
return groupBy(contributions, "Autore")
}

function normalizeGSheetJSON(response) {

const dataKeys = map(
Expand Down
67 changes: 61 additions & 6 deletions src/pages/about.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
import { NextSeo } from 'next-seo'

import {
orderBy,
map,
keys,
values,
size,
sumBy,
} from 'lodash'

import {
Container,
Typography,
List,
ListItem,
ListItemText,
Grid,
} from '@material-ui/core'

import {
REVALIDATE_INTERVAL,
GFORM_URL_ISSUE,
getGFormUrl,
getContributors,
getContributions,
} from '../config'

import {
Header,
Footer,
GridItem,
} from '../components'

export default function Index() {
export default function Index({ contributionsByContributor, totalContributionsCount }) {

const contributors = keys(contributionsByContributor)
const authoredContributionsCount = sumBy(values(contributionsByContributor), size)

return (
<>
Expand Down Expand Up @@ -62,7 +79,7 @@ export default function Index() {
<strong>Giovedì 21 maggio alle 12:00</strong> abbiamo presentato il progetto in un webinar in diretta su <a target="_blank" href="https://www.facebook.com/ondata.it/videos/565486467440217/">Facebook</a> e <a target="_blank" href="https://www.youtube.com/watch?v=YNKJxkpD1aQ">Youtube</a> con Alessio, Andrea, Alice, Jacopo e Lorenzo.
</Typography>

<iframe width="100%" height="315" src="https://www.youtube-nocookie.com/embed/YNKJxkpD1aQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="100%" height="315" src="https://www.youtube-nocookie.com/embed/YNKJxkpD1aQ" frameBorder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

<Typography variant="h2" gutterBottom>
onData - Associazione di promozione sociale
Expand All @@ -86,28 +103,56 @@ export default function Index() {
<Typography gutterBottom>
Questo sito è sviluppato e mantenuto con &hearts; da <a target="_blank" href="https://github.com/jenkin">jenkin</a>, utilizzando <a target="_blank" href="https://nextjs.org/">NextJS</a> e <a target="_blank" href="https://material-ui.com/">Material-UI</a>.
{` `}
Il nome è un'idea di <a target="_blank" href="https://www.linkedin.com/in/andreaborruso/">aborruso</a>, il graphic design di <a target="_blank" href="https://www.linkedin.com/in/jacoposolmi/">japi</a> e la progettazione del database di <a target="_blank" href="https://www.linkedin.com/in/lorenzo-perone-5aa8412/">lore</a> e <a target="_blank" href="https://www.linkedin.com/in/alicecorona/">alice</a>.
Il nome è un'idea di <a target="_blank" href="https://www.linkedin.com/in/andreaborruso/">aborruso</a>, il graphic design di <a target="_blank" href="https://www.linkedin.com/in/jacoposolmi/">japi</a> la progettazione e gestione del database di <a target="_blank" href="https://www.linkedin.com/in/lorenzo-perone-5aa8412/">lore</a> e <a target="_blank" href="https://www.linkedin.com/in/alicecorona/">alice</a>.
</Typography>

<Typography variant="h2" gutterBottom>
Contributori
</Typography>

<Typography gutterBottom>
Coming soon...
Finora hanno contribuito all'arricchimento del database {size(contributors)} persone per un totale di {authoredContributionsCount} contributi, a cui se ne aggiungono {totalContributionsCount - authoredContributionsCount} anonimi. Grazie!
</Typography>

</Container>

<Container maxWidth="md">

<Grid container spacing={1}>
{
map(
orderBy(
contributors,
contributor => size(contributionsByContributor[contributor]),
"desc"
),
contributor => (
<Grid item xs={12} sm={6} md={4} key={contributor}>
<GridItem
title={contributor}
subtitle={`${size(contributionsByContributor[contributor])} contribut${size(contributionsByContributor[contributor]) > 1 ? "i" : "o"}`}
/>
</Grid>
)
)
}
</Grid>

</Container>

<Container maxWidth="sm">

<Typography variant="h2" gutterBottom>
Roadmap
</Typography>

<Typography gutterBottom>
<List dense>
<ListItem>
<ListItemText>Elenco contributori</ListItemText>
<ListItemText>Progressive Web Application</ListItemText>
</ListItem>
<ListItem>
<ListItemText>Progressive Web Application</ListItemText>
<ListItemText>Sitemap</ListItemText>
</ListItem>
<ListItem button component="a" target="_blank" href={getGFormUrl(GFORM_URL_ISSUE)}>
<ListItemText>+ Suggerisci...</ListItemText>
Expand All @@ -123,3 +168,13 @@ export default function Index() {
</>
)
}

export async function getStaticProps() {
return {
props: {
contributionsByContributor: await getContributors(),
totalContributionsCount: size(await getContributions()),
},
unstable_revalidate: REVALIDATE_INTERVAL,
}
}