Skip to content

Commit

Permalink
Merge pull request #14 from prefeitura-rio/staging
Browse files Browse the repository at this point in the history
fix: env var
  • Loading branch information
lucastavarex authored Dec 13, 2024
2 parents e2428de + 28183d8 commit 98593e7
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 45 deletions.
6 changes: 2 additions & 4 deletions cloudbuild-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ steps:
args:
- "-c"
- |
echo "NEXT_PUBLIC_ENV=staging" > .env.production
echo "NEXT_PUBLIC_ROOT_URL_PROD=https://gw.dados.rio/plataforma-clima-staging/" >> .env.production
echo "NEXT_PUBLIC_ROOT_URL_DEV=https://gw.dados.rio/plataforma-clima-staging/" >> .env.production
echo "NEXT_PUBLIC_MAPBOX_API_KEY=pk.eyJ1IjoiZXNjcml0b3Jpb2RlZGFkb3MiLCJhIjoiY2t3bWdmcHpjMmJ2cTJucWJ4MGQ1Mm1kbiJ9.4hHJX-1pSevYoBbja7Pq4w" >> .env.production
echo "NEXT_PUBLIC_ROOT_URL=https://gw.dados.rio/plataforma-clima-staging" > .env.production && \
echo "NEXT_PUBLIC_MAPBOX_API_KEY=pk.eyJ1IjoiZXNjcml0b3Jpb2RlZGFkb3MiLCJhIjoiY2t3bWdmcHpjMmJ2cTJucWJ4MGQ1Mm1kbiJ9.4hHJX-1pSevYoBbja7Pq4w >> .env.production
# Build the container image
- name: "gcr.io/cloud-builders/docker"
Expand Down
6 changes: 2 additions & 4 deletions cloudbuild-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ steps:
args:
- "-c"
- |
echo "NEXT_PUBLIC_ENV=staging" > .env.production
echo "NEXT_PUBLIC_ROOT_URL_PROD=https://gw.dados.rio/plataforma-clima-staging/" >> .env.production
echo "NEXT_PUBLIC_ROOT_URL_DEV=https://gw.dados.rio/plataforma-clima-staging/" >> .env.production
echo "NEXT_PUBLIC_MAPBOX_API_KEY=pk.eyJ1IjoiZXNjcml0b3Jpb2RlZGFkb3MiLCJhIjoiY2t3bWdmcHpjMmJ2cTJucWJ4MGQ1Mm1kbiJ9.4hHJX-1pSevYoBbja7Pq4w" >> .env.production
echo "NEXT_PUBLIC_ROOT_URL=https://gw.dados.rio/plataforma-clima-staging" > .env.production && \
echo "NEXT_PUBLIC_MAPBOX_API_KEY=pk.eyJ1IjoiZXNjcml0b3Jpb2RlZGFkb3MiLCJhIjoiY2t3bWdmcHpjMmJ2cTJucWJ4MGQ1Mm1kbiJ9.4hHJX-1pSevYoBbja7Pq4w >> .env.production
# Build the container image
- name: "gcr.io/cloud-builders/docker"
Expand Down
6 changes: 2 additions & 4 deletions src/app/(demo)/previsao-de-chuva/v1/[...modelView]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ const ModelView = ({ params }: ModelViewProps) => {
const fetchData = async () => {
setIsLoading(true);
try {
const rootUrl = process.env.NEXT_PUBLIC_ENV === 'production'
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const apiUrl = `${rootUrl}nowcasting_models/info/v1`;
const rootUrl = process.env.NEXT_PUBLIC_ROOT_URL;
const apiUrl = `${rootUrl}/nowcasting_models/info/v1`;
const response = await fetch(apiUrl);
const result = await response.json();
setData(result);
Expand Down
4 changes: 1 addition & 3 deletions src/app/(demo)/radar/mendanha/[...radarView]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ const RadarView = ({ params }: RadarViewProps) => {
const fetchData = async () => {
setIsLoading(true);
try {
const rootUrl = process.env.NEXT_PUBLIC_ENV === 'production'
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const rootUrl = process.env.NEXT_PUBLIC_ROOT_URL;
const apiUrl = `${rootUrl}radar/info/${indice.toLowerCase()}`;
const response = await fetch(apiUrl);
const result = await response.json();
Expand Down
6 changes: 2 additions & 4 deletions src/app/(demo)/satelite/[...sateliteView]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ const SateliteView = ({ params }: SateliteViewProps) => {
const fetchData = async () => {
setIsLoading(true); // Start loading
try {
const rootUrl = process.env.NEXT_PUBLIC_ENV === "production"
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const apiUrl = `${rootUrl}satellite/info/${indice.toLowerCase()}`;
const rootUrl = process.env.NEXT_PUBLIC_ROOT_URL;
const apiUrl = `${rootUrl}/satellite/info/${indice.toLowerCase()}`;
const response = await fetch(apiUrl);
const result = await response.json();
setData(result);
Expand Down
6 changes: 2 additions & 4 deletions src/components/impa-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ export default function ModelLayer({
const product = modelView.toLowerCase();

// Determinar a URL base com base no ambiente
const rootUrl = process.env.NEXT_PUBLIC_ENV === 'production'
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const rootUrl = process.env.NEXT_PUBLIC_ROOT_URL;

// Ajustar os timestamps para o fuso horário de Brasília antes de enviar ao backend
const apiUrl = `${rootUrl}impa_models/impa/gif/${product}?start_time=${startTimeBrasilia.toISOString()}&end_time=${currentTimeBrasilia.toISOString()}`;
const apiUrl = `${rootUrl}/impa_models/impa/gif/${product}?start_time=${startTimeBrasilia.toISOString()}&end_time=${currentTimeBrasilia.toISOString()}`;
const response = await fetch(apiUrl);

if (!response.ok) {
Expand Down
6 changes: 2 additions & 4 deletions src/components/radar-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ export default function RadarLayer({
// const product = "reflectivity".toLowerCase(); // reflectivity

// Determinar a URL base com base no ambiente
const rootUrl = process.env.NEXT_PUBLIC_ENV === 'production'
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const rootUrl = process.env.NEXT_PUBLIC_ROOT_URL;

// Ajustar os timestamps para o fuso horário de Brasília antes de enviar ao backend
const apiUrl = `${rootUrl}radar/mendanha/${product}?start_time=${startTimeBrasilia.toISOString()}&end_time=${currentTimeBrasilia.toISOString()}`;
const apiUrl = `${rootUrl}/radar/mendanha/${product}?start_time=${startTimeBrasilia.toISOString()}&end_time=${currentTimeBrasilia.toISOString()}`;
const response = await fetch(apiUrl);

if (!response.ok) {
Expand Down
10 changes: 4 additions & 6 deletions src/components/rionowcast-v1-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ export default function ModelLayer({
const endTimeBrasilia = new Date(currentTime.getTime() + 60 * 1000);

// Determinar a URL base com base no ambiente
const rootUrl = process.env.NEXT_PUBLIC_ENV === 'production'
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const rootUrl = process.env.NEXT_PUBLIC_ROOT_URL;

const endpoints = [
`${rootUrl}nowcasting_models/rionowcast/gif/v1/1h?start_time=${currentTimeBrasilia.toISOString()}&end_time=${endTimeBrasilia.toISOString()}`,
`${rootUrl}nowcasting_models/rionowcast/gif/v1/2h?start_time=${currentTimeBrasilia.toISOString()}&end_time=${endTimeBrasilia.toISOString()}`,
`${rootUrl}nowcasting_models/rionowcast/gif/v1/3h?start_time=${currentTimeBrasilia.toISOString()}&end_time=${endTimeBrasilia.toISOString()}`
`${rootUrl}/nowcasting_models/rionowcast/gif/v1/1h?start_time=${currentTimeBrasilia.toISOString()}&end_time=${endTimeBrasilia.toISOString()}`,
`${rootUrl}/nowcasting_models/rionowcast/gif/v1/2h?start_time=${currentTimeBrasilia.toISOString()}&end_time=${endTimeBrasilia.toISOString()}`,
`${rootUrl}/nowcasting_models/rionowcast/gif/v1/3h?start_time=${currentTimeBrasilia.toISOString()}&end_time=${endTimeBrasilia.toISOString()}`
];

const responses = await Promise.all(endpoints.map(endpoint => fetch(endpoint)));
Expand Down
6 changes: 2 additions & 4 deletions src/components/satelite-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ export default function SatelliteLayer({
const product = sateliteView.toLowerCase();

// Determinar a URL base com base no ambiente
const rootUrl = process.env.NEXT_PUBLIC_ENV === 'production'
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const rootUrl = process.env.NEXT_PUBLIC_ROOT_URL;

// Ajustar os timestamps para o fuso horário de Brasília antes de enviar ao backend
const apiUrl = `${rootUrl}satellite/goes16/gif/${product}?start_time=${startTimeBrasilia.toISOString()}&end_time=${currentTimeBrasilia.toISOString()}`;
const apiUrl = `${rootUrl}/satellite/goes16/gif/${product}?start_time=${startTimeBrasilia.toISOString()}&end_time=${currentTimeBrasilia.toISOString()}`;
const response = await fetch(apiUrl);

if (!response.ok) {
Expand Down
6 changes: 2 additions & 4 deletions src/components/tabs-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ export function TabsDemo({ sateliteView }: SateliteContentProps) {
useEffect(() => {
const fetchData = async () => {
try {
const rootUrl = process.env.NEXT_PUBLIC_ENV === 'production'
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const rootUrl = process.env.NEXT_PUBLIC_ROOT_URL;

const response = await fetch(`${rootUrl}satellite/info/${sateliteView.toLowerCase()}`);
const response = await fetch(`${rootUrl}/satellite/info/${sateliteView.toLowerCase()}`);
const result = await response.json();
setData(result);
} catch (error) {
Expand Down
6 changes: 2 additions & 4 deletions src/components/ui/line-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ export function LineChartComponent({ valueRange, stepRange, name, sateliteView,
try {
const product = sateliteView.toLowerCase();

const rootUrl = process.env.NEXT_PUBLIC_ENV === 'production'
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const rootUrl = process.env.NEXT_PUBLIC_ROOT_URL;

const response = await fetch(
`${rootUrl}satellite/goes16/chart/${product}?start_time=${startTimeBrasilia.toISOString()}&end_time=${currentTimeBrasilia.toISOString()}`
`${rootUrl}/satellite/goes16/chart/${product}?start_time=${startTimeBrasilia.toISOString()}&end_time=${currentTimeBrasilia.toISOString()}`
);
const jsonData = await response.json();
// console.log(jsonData)
Expand Down

0 comments on commit 98593e7

Please sign in to comment.