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

250117 Release #2475

Merged
merged 41 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b66ce96
Rename "outcomes" to "report".
ziggabyte Dec 18, 2024
853cbdf
Rename canvass... to areaAssignment...
ziggabyte Dec 18, 2024
a78e97d
Rename from "areas" to "geography"
ziggabyte Dec 18, 2024
235e791
Localise messages in Geography feature.
ziggabyte Dec 18, 2024
6bcf8ae
Add <title> to area assignment pages and localise tab labels.
ziggabyte Dec 18, 2024
2e19256
Localise the area assignment layout file.
ziggabyte Dec 18, 2024
ae57123
Rename "place*" to "location*"
ziggabyte Dec 18, 2024
2ab60a4
Correct name of file.
ziggabyte Dec 19, 2024
faf80cd
Localise overview tab and change structure of messageIds file.
ziggabyte Dec 19, 2024
4736de2
Rename component for clarity.
ziggabyte Dec 19, 2024
4035d17
Localise map tab.
ziggabyte Dec 19, 2024
1c0fb16
Localise assignees tab.
ziggabyte Dec 19, 2024
3d9ed74
Add default titles to activity list- and overview cards
ziggabyte Dec 19, 2024
cc8ef86
Move code for the activist portal into new "canvass" feature folder.
ziggabyte Dec 19, 2024
600f3a8
Localise Canvass feature.
ziggabyte Dec 20, 2024
80299c0
Rename from VisitWizard to HouseholdVisit
ziggabyte Dec 20, 2024
ef2fc35
Add "..Page" to components that were missing it, for consistency.
ziggabyte Dec 20, 2024
d1d5d03
Rename components in canvass feature to be called things with Canvass.
ziggabyte Dec 20, 2024
035f2d8
Correct two mistakes in the transaltions.
ziggabyte Dec 20, 2024
6c9db8c
Merge branch 'main' of github.com:zetkin/app.zetkin.org into undocume…
ziggabyte Dec 20, 2024
67a51a6
Change some stray canvassAssId to areaAssId
ziggabyte Dec 20, 2024
8a1f4e8
move map page to correct folder
ziggabyte Dec 20, 2024
d0979ec
Move instructions page to correct route
richardolsson Dec 29, 2024
559976f
Merge branch 'main' into undocumented/canvass-copy-writing
richardolsson Dec 29, 2024
d9927cb
Re-rename feature back to being called "areas".
ziggabyte Jan 7, 2025
fde00c5
Use ids for the graphs instead of translations.
ziggabyte Jan 7, 2025
1fd1549
Change search-and-replace mistake
ziggabyte Jan 7, 2025
0a13d45
Update message.
ziggabyte Jan 7, 2025
97ce643
Create a "geography" feature again, and put the GeographyMap componen…
ziggabyte Jan 7, 2025
34fdee5
Set titles of areas, assignments, locations and households to default…
ziggabyte Jan 7, 2025
3b3c091
Merge branch 'main' of github.com:zetkin/app.zetkin.org into undocume…
ziggabyte Jan 7, 2025
f879d4b
Rename misspelled variable.
ziggabyte Jan 13, 2025
322287f
disable email sender
helihard Jan 13, 2025
ce2f307
Merge pull request #2464 from zetkin/issue-2462/disable-email-sender
richardolsson Jan 13, 2025
b1e9b77
Merge pull request #2443 from zetkin/undocumented/canvass-copy-writing
ziggabyte Jan 13, 2025
e88bcb5
add multiline prop to text field
helihard Jan 14, 2025
0e7a4dc
Merge pull request #2466 from zetkin/issue-2465/multiline-text-input
richardolsson Jan 14, 2025
6bef8b7
Update translations per 250115
richardolsson Jan 15, 2025
e904167
Fix CI configuration problem
richardolsson Jan 16, 2025
1becedf
Merge pull request #2473 from zetkin/undocumented/github-artefact-v4
richardolsson Jan 16, 2025
323e579
Merge pull request #2469 from zetkin/undocumented/update-translations…
richardolsson Jan 17, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/reusable-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Test
run: yarn ${{ inputs.yarn-test-script }}

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always() && inputs.upload-path
with:
path: ${{ inputs.upload-path }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import mongoose from 'mongoose';
import { NextRequest, NextResponse } from 'next/server';

import asOrgAuthorized from 'utils/api/asOrgAuthorized';
import { CanvassAssignmentModel } from 'features/canvassAssignments/models';
import { AreaAssignmentModel } from 'features/areaAssignments/models';

type RouteMeta = {
params: {
Expand All @@ -26,7 +26,7 @@ export async function DELETE(request: NextRequest, { params }: RouteMeta) {
apiClient;
orgId;

const assignmentModel = await CanvassAssignmentModel.findOne({
const assignmentModel = await AreaAssignmentModel.findOne({
_id: params.assignmentId,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ import { NextRequest, NextResponse } from 'next/server';

import { AreaModel } from 'features/areas/models';
import {
CanvassAssignmentModel,
PlaceModel,
} from 'features/canvassAssignments/models';
AreaAssignmentModel,
LocationModel,
} from 'features/areaAssignments/models';
import {
AreaCardData,
AreaGraphData,
Household,
Visit,
ZetkinCanvassSession,
ZetkinPlace,
} from 'features/canvassAssignments/types';
import getAreaData from 'features/canvassAssignments/utils/getAreaData';
import isPointInsidePolygon from 'features/canvassAssignments/utils/isPointInsidePolygon';
ZetkinAreaAssignmentSession,
ZetkinLocation,
} from 'features/areaAssignments/types';
import getAreaData from 'features/areaAssignments/utils/getAreaData';
import isPointInsidePolygon from 'features/canvass/utils/isPointInsidePolygon';
import asOrgAuthorized from 'utils/api/asOrgAuthorized';
import { ZetkinPerson } from 'utils/types/zetkin';
import { ZetkinArea } from 'features/areas/types';

type RouteMeta = {
params: {
canvassAssId: string;
areaAssId: string;
orgId: string;
};
};
Expand All @@ -37,15 +37,15 @@ export async function GET(request: NextRequest, { params }: RouteMeta) {
async ({ apiClient, orgId }) => {
await mongoose.connect(process.env.MONGODB_URL || '');

const assignmentModel = await CanvassAssignmentModel.findOne({
_id: params.canvassAssId,
const assignmentModel = await AreaAssignmentModel.findOne({
_id: params.areaAssId,
}).lean();

if (!assignmentModel) {
return new NextResponse(null, { status: 404 });
}

const sessions: ZetkinCanvassSession[] = [];
const sessions: ZetkinAreaAssignmentSession[] = [];

for await (const sessionData of assignmentModel.sessions) {
const person = await apiClient.get<ZetkinPerson>(
Expand Down Expand Up @@ -92,8 +92,8 @@ export async function GET(request: NextRequest, { params }: RouteMeta) {
...new Map(areas.map((area) => [area.id, area])).values(),
];

const allPlaceModels = await PlaceModel.find({ orgId }).lean();
const allPlaces: ZetkinPlace[] = allPlaceModels.map((model) => ({
const allLocationModels = await LocationModel.find({ orgId }).lean();
const allLocations: ZetkinLocation[] = allLocationModels.map((model) => ({
description: model.description,
households: model.households,
id: model._id.toString(),
Expand All @@ -102,19 +102,19 @@ export async function GET(request: NextRequest, { params }: RouteMeta) {
title: model.title,
}));

type PlaceWithAreaId = ZetkinPlace & { areaId: ZetkinArea['id'] };
type LocationWithAreaId = ZetkinLocation & { areaId: ZetkinArea['id'] };

//Find places in the given areas
const placesInAreas: PlaceWithAreaId[] = [];
//Find locations in the given areas
const locationsInAreas: LocationWithAreaId[] = [];
uniqueAreas.forEach((area) => {
allPlaces.forEach((place) => {
const placeIsInArea = isPointInsidePolygon(
{ lat: place.position.lat, lng: place.position.lng },
allLocations.forEach((location) => {
const locationIsInArea = isPointInsidePolygon(
{ lat: location.position.lat, lng: location.position.lng },
area.points.map((point) => ({ lat: point[0], lng: point[1] }))
);

if (placeIsInArea) {
placesInAreas.push({ ...place, areaId: area.id });
if (locationIsInArea) {
locationsInAreas.push({ ...location, areaId: area.id });
}
});
});
Expand All @@ -127,12 +127,12 @@ export async function GET(request: NextRequest, { params }: RouteMeta) {
let firstVisit: Date = new Date();
let lastVisit: Date = new Date();

allPlaces.forEach((place) => {
const placeVisits = place.households
allLocations.forEach((location) => {
const locationVisits = location.households
.flatMap((household) => household.visits)
.filter((visit) => visit.canvassAssId === params.canvassAssId);
.filter((visit) => visit.areaAssId === params.areaAssId);

filteredVisitsInAllAreas.push(...placeVisits);
filteredVisitsInAllAreas.push(...locationVisits);
});

if (filteredVisitsInAllAreas.length > 0) {
Expand Down Expand Up @@ -167,18 +167,20 @@ export async function GET(request: NextRequest, { params }: RouteMeta) {
const areaVisitsData: AreaGraphData[] = [];
const householdList: Household[] = [];

allPlaces.forEach((place) => {
const placeIsInArea = isPointInsidePolygon(
{ lat: place.position.lat, lng: place.position.lng },
allLocations.forEach((location) => {
const locationIsInArea = isPointInsidePolygon(
{ lat: location.position.lat, lng: location.position.lng },
area.points.map((point) => ({ lat: point[0], lng: point[1] }))
);

if (placeIsInArea) {
const filteredHouseholds = place.households.filter((household) => {
return household.visits.filter(
(visit) => visit.canvassAssId === params.canvassAssId
);
});
if (locationIsInArea) {
const filteredHouseholds = location.households.filter(
(household) => {
return household.visits.filter(
(visit) => visit.areaAssId === params.areaAssId
);
}
);
householdList.push(...filteredHouseholds);
}
});
Expand All @@ -200,17 +202,17 @@ export async function GET(request: NextRequest, { params }: RouteMeta) {
});

//Visits outside assigned areas logic
const idsOfPlacesInAreas = new Set(
placesInAreas.map((place) => place.id)
const idsOfLocationsInAreas = new Set(
locationsInAreas.map((location) => location.id)
);
const placesOutsideAreas = allPlaces.filter(
(place) => !idsOfPlacesInAreas.has(place.id)
const locationsOutsideAreas = allLocations.filter(
(location) => !idsOfLocationsInAreas.has(location.id)
);

placesOutsideAreas.forEach((place) => {
place.households.forEach((household) => {
locationsOutsideAreas.forEach((location) => {
location.households.forEach((household) => {
household.visits.forEach((visit) => {
if (visit.canvassAssId == params.canvassAssId) {
if (visit.areaAssId == params.areaAssId) {
householdsOutsideAreasList.push(household);
}
});
Expand Down
Loading
Loading