Skip to content

Commit

Permalink
não foi todas
Browse files Browse the repository at this point in the history
  • Loading branch information
dvalenca committed Jul 8, 2023
1 parent 5262aa7 commit 832fbb9
Show file tree
Hide file tree
Showing 11 changed files with 500 additions and 38 deletions.
11 changes: 11 additions & 0 deletions .vercel/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
> Why do I have a folder named ".vercel" in my project?
The ".vercel" folder is created when you link a directory to a Vercel project.

> What does the "project.json" file contain?
The "project.json" file contains:
- The ID of the Vercel project that you linked ("projectId")
- The ID of the user or team your Vercel project is owned by ("orgId")

> Should I commit the ".vercel" folder?
No, you should not share the ".vercel" folder with anyone.
Upon creation, it will be automatically added to your ".gitignore" file.
1 change: 1 addition & 0 deletions .vercel/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"projectId":"prj_dUsfCJRZ1yXSj2jTboiXtQ0pzcQK","orgId":"team_QLtK9YjmM3GqsvHWRnkrtmQR"}
55 changes: 43 additions & 12 deletions app/contagens/configuration.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,86 @@
import { IntlNumber, IntlPercentil } from "../../utils";

export const allCountsStatistics = (summaryData, counts) => {
const {totalAmount, numberOfCounts, MaximumValue} = {...summaryData}
export const allCountsStatistics = (summaryData) => {
const { total, number_counts, where_max_count, different_counts_points } = {
...summaryData,
};
return [
{
title: "Total de ciclistas",
value: IntlNumber(totalAmount),
value: IntlNumber(total),
},
{
title: "Contagens Realizadas",
value: IntlNumber(numberOfCounts),
value: IntlNumber(number_counts),
},
{ title: "Pontos Monitorados", value: IntlNumber(counts) },
{ title: "Pontos Monitorados", value: IntlNumber(different_counts_points) },
{
title: "Máximo em um ponto",
value: IntlNumber(MaximumValue),
value: IntlNumber(where_max_count.total_cyclists),
},
];
};

export const CardsData = (summaryData) => {
const {
total_cyclists,
total_cargo,
total_helmet,
total_juveniles,
total_motor,
total_ride,
total_service,
total_shared_bike,
total_sidewalk,
total_women,
total_wrong_way,
} = { ...summaryData };

return [
{
label: "Mulheres",
icon: "women",
data: IntlPercentil(summaryData.totalWomenPercentile),
data: IntlPercentil(total_women / total_cyclists),
},
{
label: "Crianças e Adolescentes",
icon: "children",
data: IntlPercentil(summaryData.totalChildrenPercentile),
data: IntlPercentil(total_juveniles / total_cyclists),
},
{
label: "Carona",
icon: "ride",
data: IntlPercentil(total_ride / total_cyclists),
},
{
label: "Capacete",
icon: "helmet",
data: IntlPercentil(summaryData.totalHelmetPercentile),
data: IntlPercentil(total_helmet / total_cyclists),
},
{
label: "Serviço",
icon: "service",
data: IntlPercentil(summaryData.totalServicePercentile),
data: IntlPercentil(total_service / total_cyclists),
},
{
label: "Cargueira",
icon: "cargo",
data: IntlPercentil(summaryData.totalCargoPercentile),
data: IntlPercentil(total_cargo / total_cyclists),
},
{
label: "Compartilhada",
icon: "shared_bike",
data: IntlPercentil(total_shared_bike / total_cyclists),
},
{
label: "Calçada",
icon: "sidewalk", //CRIAR!
data: IntlPercentil(total_sidewalk / total_cyclists),
},
{
label: "Contramão",
icon: "wrong_way",
data: IntlPercentil(summaryData.totalWrongWayPercentile),
data: IntlPercentil(total_wrong_way / total_cyclists),
},
];
};
37 changes: 19 additions & 18 deletions app/contagens/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { groupBy, IntlDateStr } from "../../utils";
import {
COUNTINGS_DATA,
COUNTINGS_SUMMARY_DATA,
COUNTINGS_SUMMARY_DATA_NEW,
COUNTINGS_PAGE_DATA,
} from "../../servers";
import { allCountsStatistics, CardsData } from "./configuration";
Expand All @@ -29,44 +30,45 @@ const fetchData = async () => {
const dataJson = await dataRes.json();
const data = dataJson.data;

const summaryDataRes = await fetch(COUNTINGS_SUMMARY_DATA, {
const summaryDataResNEW = await fetch(COUNTINGS_SUMMARY_DATA_NEW, {
cache: "no-cache",
});
const summaryDataJson = await summaryDataRes.json();
const summaryData = summaryDataJson.data[0];
const summaryDataJsonNEW = await summaryDataResNEW.json();
const summaryDataNEW = summaryDataJsonNEW.summary;
const dataNEW = summaryDataJsonNEW.counts;

const pageDataRes = await fetch(COUNTINGS_PAGE_DATA, { cache: "no-cache" });
const pageData = await pageDataRes.json();

return { data, summaryData, pageData };
return { data, pageData, summaryDataNEW, dataNEW };
};

export default async function Contagens() {
const { data, summaryData, pageData } = await fetchData();
const { data, pageData, summaryDataNEW, dataNEW } = await fetchData();
const { cover, description, objective, archives } = pageData;

const controlPanel = [{
type:'ameciclo',
color: '#008888'
},{
type: 'prefeitura',
color: "#ef4444"
}]
console.log(dataNEW)


let pointsData: pointData[] = data.map((d) => ({
key: d._id,
let pointsData: pointData[] = dataNEW.map((d) => ({
key: d.id,
type: 'ameciclo',
latitude: d.location.coordinates[0],
longitude: d.location.coordinates[1],
latitude: d.coordinates.x,
longitude: d.coordinates.y,
popup: {
name: d.name,
total: d.summary.total,
total: d.total_cyclists,
date: IntlDateStr(d.date),
url: `/contagens/${d._id}`,
url: `/contagens/${d.id}`,
obs: ""
},
size: Math.round(d.summary.total / 250) + 5,
size: Math.round(d.total_cyclists / 250) + 5,
color: "#008888"
}));
const pcrPointsData: pointData[] = pcr_countings.map((d, index)=> ({
Expand All @@ -87,8 +89,7 @@ export default async function Contagens() {
pointsData = pointsData.concat(pcrPointsData);

const countsGroupedByLocation = groupBy(data, (count) => count.name);
const countsGroupedArray = Object.entries(countsGroupedByLocation);
const cards = CardsData(summaryData);
const cards = CardsData(summaryDataNEW);
const docs = archives.map((a) => {
return {
title: a.filename,
Expand All @@ -103,7 +104,7 @@ export default async function Contagens() {
<Breadcrumb {...crumb} />
<StatisticsBox
title={"Estatísticas Gerais"}
boxes={allCountsStatistics(summaryData, countsGroupedArray.length)}
boxes={allCountsStatistics(summaryDataNEW)}
/>
<ExplanationBoxes
boxes={[
Expand All @@ -116,7 +117,7 @@ export default async function Contagens() {
/>
<InfoCards cards={cards} />
<Map pointsData={pointsData} controlPanel={controlPanel} />
<ContagensTable data={data} />
<ContagensTable data={dataNEW} />
<CardsSession
title={"Documentos para realizar contagens de ciclistas."}
cards={docs}
Expand Down
1 change: 1 addition & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
Loading

0 comments on commit 832fbb9

Please sign in to comment.