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

naxa/fix/6339 use default changeset comment in ohsome api #80

Merged
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
4 changes: 2 additions & 2 deletions frontend/src/api/stats.js
Original file line number Diff line number Diff line change
@@ -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');
@@ -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}-%2A`, {
signal,
});
};
6 changes: 4 additions & 2 deletions frontend/src/components/teamsAndOrgs/featureStats.js
Original file line number Diff line number Diff line change
@@ -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';
@@ -13,7 +13,9 @@ 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}-%2A`,
);
const { edits, buildings, roads } = response.data.result;
setStats({
edits,
3 changes: 3 additions & 0 deletions frontend/src/config/index.js
Original file line number Diff line number Diff line change
@@ -184,3 +184,6 @@ export const DROPZONE_SETTINGS = {
// At time of writing, this workaround is only needed on Chromium based browsers.
noClick: true,
};

// TM_DEFAULT_CHANGESET_COMMENT without '#'
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
@@ -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 {
@@ -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}-%2A`, (req, res, ctx) => {
return res(ctx.json(homepageStats));
}),
rest.get(`${OHSOME_STATS_BASE_URL}/hot-tm-user`, (req, res, ctx) => {