Skip to content

Commit

Permalink
Add default changeset comment from env in ohsome API
Browse files Browse the repository at this point in the history
- Related to hotosm#6339
  • Loading branch information
royallsilwallz committed Apr 18, 2024
1 parent 7d26e0c commit 6145b1a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions frontend/src/api/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';

import { fetchExternalJSONAPI } from '../network/genericJSONRequest';
import api from './apiClient';
import { OHSOME_STATS_BASE_URL } from '../config';
import { OHSOME_STATS_BASE_URL, defaultChangesetComment } from '../config';

const ohsomeProxyAPI = (url) => {
const token = localStorage.getItem('token');
Expand Down Expand Up @@ -39,7 +39,7 @@ export const useProjectStatisticsQuery = (projectId) => {

export const useOsmStatsQuery = () => {
const fetchOsmStats = ({ signal }) => {
return api().get(`${OHSOME_STATS_BASE_URL}/stats/hotosm-project-%2A`, {
return api().get(`${OHSOME_STATS_BASE_URL}/stats/${defaultChangesetComment}`, {
signal,
});
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/teamsAndOrgs/featureStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormattedMessage } from 'react-intl';

import messages from './messages';
import userDetailMessages from '../userDetail/messages';
import { OHSOME_STATS_BASE_URL } from '../../config';
import { OHSOME_STATS_BASE_URL, defaultChangesetComment } from '../../config';
import { RoadIcon, HomeIcon, WavesIcon, MarkerIcon } from '../svgIcons';
import { StatsCard } from '../statsCard';
import StatsTimestamp from '../statsTimestamp';
Expand All @@ -13,7 +13,7 @@ export const FeatureStats = () => {
const [stats, setStats] = useState({ edits: 0, buildings: 0, roads: 0, pois: 0, waterways: 0 });
const getStats = async () => {
try {
const response = await axios.get(`${OHSOME_STATS_BASE_URL}/stats/hotosm-project-%2A`);
const response = await axios.get(`${OHSOME_STATS_BASE_URL}/stats/${defaultChangesetComment}`);
const { edits, buildings, roads } = response.data.result;
setStats({
edits,
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,5 @@ export const DROPZONE_SETTINGS = {
// At time of writing, this workaround is only needed on Chromium based browsers.
noClick: true,
};

export const defaultChangesetComment = TM_DEFAULT_CHANGESET_COMMENT.replace('#', '');
4 changes: 2 additions & 2 deletions frontend/src/network/tests/server-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import {
ohsomeNowMetadata,
} from './mockData/miscellaneous';
import tasksGeojson from '../../utils/tests/snippets/tasksGeometry';
import { API_URL, OHSOME_STATS_BASE_URL } from '../../config';
import { API_URL, OHSOME_STATS_BASE_URL, defaultChangesetComment } from '../../config';
import { notifications, ownCountUnread } from './mockData/notifications';
import { authLogin, setUser, userRegister } from './mockData/auth';
import {
Expand Down Expand Up @@ -349,7 +349,7 @@ const handlers = [
return res(ctx.json(systemStats));
}),
// EXTERNAL API
rest.get(`${OHSOME_STATS_BASE_URL}/stats/hotosm-project-%2A`, (req, res, ctx) => {
rest.get(`${OHSOME_STATS_BASE_URL}/stats/${defaultChangesetComment}`, (req, res, ctx) => {
return res(ctx.json(homepageStats));
}),
rest.get(`${OHSOME_STATS_BASE_URL}/hot-tm-user`, (req, res, ctx) => {
Expand Down

0 comments on commit 6145b1a

Please sign in to comment.