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

Release - 2024-August [Fix] #963

Merged
merged 4 commits into from
Aug 16, 2024
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: MapSwipe Workers

on: [push]

env:
COMPOSE_FILE: docker-compose.yaml:docker-compose-ci.yaml

jobs:
build:

Expand Down Expand Up @@ -77,6 +80,7 @@ jobs:
POSTGRES_DB: postgres
OSMCHA_API_KEY: ${{ secrets.OSMCHA_API_KEY }}
DJANGO_SECRET_KEY: test-django-secret-key
COMPOSE_FILE: ../docker-compose.yaml:../docker-compose-ci.yaml
run: |
docker compose run --rm mapswipe_workers_creation python -m unittest discover --verbose --start-directory tests/unittests/
docker compose run --rm mapswipe_workers_creation bash -c 'pip install pytest && pytest -ra -v --durations=10 tests/integration/'
Expand Down
8 changes: 8 additions & 0 deletions docker-compose-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Quick hack to avoid on GH CI
# Check .github/workflows/actions.yml for usages
# Related error:
# failed to create network python-mapswipe-workers_mapswipe_network:
# Error response from daemon: Pool overlaps with other one on this address space
networks:
mapswipe_network:
ipam: !reset null
14 changes: 6 additions & 8 deletions firebase/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ exports.addProjectTopicKey = functions.https.onRequest(async (_, res) => {
const isEmptyProject = Object.keys(data).length === 0;
if (isEmptyProject) {
res.status(404).send('No projects found');
}

if (!isEmptyProject && data) {
} else {
const newProjectData: {[key: string]: string} = {};

Object.keys(data).forEach((id) => {
if (data[id]?.projectTopic) {
const newProjectTopicKey = formatProjectTopic(data[id].projectTopic);
const projectData = data[id];

if (projectData?.name) {
const newProjectTopicKey = formatProjectTopic(projectData.name);
newProjectData[`v2/projects/${id}/projectTopicKey`] = newProjectTopicKey;
}
});
Expand All @@ -383,9 +383,7 @@ exports.addUserNameLowercase = functions.https.onRequest(async (_, res) => {
const isEmptyUser = Object.keys(data).length === 0;
if (isEmptyUser) {
res.status(404).send('No user found');
}

if (!isEmptyUser && data) {
} else {
const newUserData: {[key: string]: string} = {};

Object.keys(data).forEach((id) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function BasicProjectInfoForm(props: Props<PartialProjectFormType>) {
hint="We will generate you project name based on your inputs above."
readOnly
placeholder="[Project Topic] - [Project Region] ([Task Number]) [Requesting Organisation]"
// error={error?.name}
error={error?.name}
disabled={disabled}
/>
<div className={styles.inputGroup}>
Expand Down
9 changes: 4 additions & 5 deletions manager-dashboard/app/views/NewProject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function NewProject(props: Props) {
visibility,
filter,
filterText,
projectTopic,
name,
...valuesToCopy
} = finalValues;

Expand Down Expand Up @@ -331,8 +331,7 @@ function NewProject(props: Props) {
// NOTE: All the user don't have permission to access draft project
// FIXME: The firebase rules need to be changed to perform this on draft project
const database = getDatabase();
const projectTopicKeyLowercase = (projectTopic?.trim())?.toLowerCase() as string;
const projectTopicKey = formatProjectTopic(projectTopicKeyLowercase);
const projectTopicKey = formatProjectTopic(name);
const projectRef = databaseRef(database, 'v2/projects/');

const prevProjectNameQuery = query(
Expand All @@ -350,7 +349,7 @@ function NewProject(props: Props) {
setError((prevErr) => ({
...getErrorObject(prevErr),
[nonFieldError]: 'A project with this name already exists, please use a different project name (Please note that the name comparison is not case sensitive)',
projectTopic: 'A project with this name already exists',
name: 'A project with this name already exists',
}));
setProjectSubmissionStatus(undefined);
return;
Expand All @@ -369,7 +368,7 @@ function NewProject(props: Props) {

const uploadData = {
...valuesToCopy,
projectTopic,
name,
projectTopicKey,
filter: finalFilter,
image: downloadUrl,
Expand Down
Loading