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-08-19 #8923

Merged
merged 39 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1664f92
[TAN-2645] Use props[publication_statuses] param in Queries::Projects
jinjagit Sep 17, 2024
2cd22b6
Merge branch 'master' into TAN-2645-filter-archived-and-or-published-…
jinjagit Sep 17, 2024
b483314
[TAN-2645] Fix spec
jinjagit Sep 17, 2024
f18f90d
[TAN-2645] Add tests of filtering by publication_status(es)
jinjagit Sep 17, 2024
8b16032
Update query to add publication status
EdwinKato Sep 18, 2024
65cb823
Use new publication status in query
EdwinKato Sep 18, 2024
14716da
Add option to select the publication status to the projects settings
EdwinKato Sep 18, 2024
e14a8c8
Translations updated by CI (extract-intl)
Sep 18, 2024
b970f8c
Change the default label to projects
EdwinKato Sep 18, 2024
77fec71
Translations updated by CI (extract-intl)
Sep 18, 2024
47e00a9
Merge pull request #8909 from CitizenLabDotCo/TAN-2645-filter-archive…
EdwinKato Sep 18, 2024
c150749
Merge pull request #8902 from CitizenLabDotCo/TAN-2645-filter-archive…
EdwinKato Sep 19, 2024
28d38d4
New translations en.json (French)
cl-dev-bot Sep 19, 2024
4be803d
New translations en.json (Spanish)
cl-dev-bot Sep 19, 2024
d8548df
New translations en.json (Arabic)
cl-dev-bot Sep 19, 2024
47b5924
New translations en.json (Danish)
cl-dev-bot Sep 19, 2024
848e33a
New translations en.json (German)
cl-dev-bot Sep 19, 2024
d01ce6e
New translations en.json (Finnish)
cl-dev-bot Sep 19, 2024
8a20278
New translations en.json (Dutch)
cl-dev-bot Sep 19, 2024
74ba2ee
New translations en.yml (Norwegian)
cl-dev-bot Sep 19, 2024
d9ec918
New translations en.json (Norwegian)
cl-dev-bot Sep 19, 2024
5fda3c4
New translations en.json (Norwegian)
cl-dev-bot Sep 19, 2024
c28b2d8
New translations en.json (Polish)
cl-dev-bot Sep 19, 2024
ee33278
New translations en.json (Serbian (Cyrillic))
cl-dev-bot Sep 19, 2024
8992774
New translations en.json (Swedish)
cl-dev-bot Sep 19, 2024
f870cb9
New translations en.json (Turkish)
cl-dev-bot Sep 19, 2024
ab83ceb
New translations en.json (Portuguese, Brazilian)
cl-dev-bot Sep 19, 2024
3225497
New translations en.json (Spanish, Chile)
cl-dev-bot Sep 19, 2024
f695b83
New translations en.json (Croatian)
cl-dev-bot Sep 19, 2024
c1b86d7
New translations en.json (Latvian)
cl-dev-bot Sep 19, 2024
0695908
New translations en.json (English, Canada)
cl-dev-bot Sep 19, 2024
744d93c
New translations en.json (English, United Kingdom)
cl-dev-bot Sep 19, 2024
090ad2e
New translations en.json (Welsh)
cl-dev-bot Sep 19, 2024
a9897c8
New translations en.json (Serbian (Latin))
cl-dev-bot Sep 19, 2024
9a1bcfa
New translations en.json (Dutch, Belgium)
cl-dev-bot Sep 19, 2024
d8f84fc
New translations en.json (English, Ireland)
cl-dev-bot Sep 19, 2024
c118a45
New translations en.json (French, Belgium)
cl-dev-bot Sep 19, 2024
dae44cc
New translations en.json (Acholi)
cl-dev-bot Sep 19, 2024
f539b55
Merge pull request #8922 from CitizenLabDotCo/l10n_master
EdwinKato Sep 19, 2024
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ReportBuilder
class Queries::Projects < ReportBuilder::Queries::Base
def run_query(start_at: nil, end_at: nil, **_other_props)
def run_query(start_at: nil, end_at: nil, publication_statuses: [], **_other_props)
# publication_statuses = %w[published archived] # TODO: remove this debug line
start_date, end_date = TimeBoundariesParser.new(start_at, end_at).parse

overlapping_project_ids = Phase
Expand All @@ -10,7 +11,7 @@ def run_query(start_at: nil, end_at: nil, **_other_props)
overlapping_projects = Project
.joins(:admin_publication)
.where(id: overlapping_project_ids)
.where(admin_publication: { publication_status: 'published' })
.where(admin_publication: { publication_status: publication_statuses })

periods = Phase
.select(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
describe '#run_query' do
before_all do
# 2020
past_project = create(:project)
@past_project = create(:project)
create(
:phase,
project: past_project,
project: @past_project,
start_at: Date.new(2020, 2, 1),
end_at: Date.new(2020, 3, 1),
with_permissions: true
Expand All @@ -29,11 +29,16 @@
@project3 = create(:project)
create(:phase, project: @project3, start_at: Date.new(2022, 2, 1), end_at: nil)

# Project not published (should be filtered out)
# Draft project
project4 = create(:project)
project4.admin_publication.update!(publication_status: 'draft')
create(:phase, project: project4, start_at: Date.new(2022, 2, 1), end_at: nil)

# Archived project
@project5 = create(:project)
@project5.admin_publication.update!(publication_status: 'archived')
create(:phase, project: @project5, start_at: Date.new(2022, 2, 1), end_at: nil)

# Empty project
create(:project)

Expand All @@ -45,7 +50,12 @@
end

it 'returns overlapping projects' do
result = query.run_query(start_at: Date.new(2021, 1, 1), end_at: Date.new(2021, 4, 1))
result = query.run_query(
start_at: Date.new(2021, 1, 1),
end_at: Date.new(2021, 4, 1),
publication_statuses: %w[published]
)

expect(result[:projects].count).to eq(2)

expect(
Expand All @@ -54,7 +64,12 @@
end

it 'returns overlapping projects when last phase has no end date' do
result = query.run_query(start_at: Date.new(2022, 1, 1), end_at: Date.new(2022, 4, 1))
result = query.run_query(
start_at: Date.new(2022, 1, 1),
end_at: Date.new(2022, 4, 1),
publication_statuses: %w[published]
)

expect(result[:projects].count).to eq(2)

expect(
Expand All @@ -63,12 +78,22 @@
end

it 'returns project images' do
result = query.run_query(start_at: Date.new(2021, 1, 1), end_at: Date.new(2021, 4, 1))
result = query.run_query(
start_at: Date.new(2021, 1, 1),
end_at: Date.new(2021, 4, 1),
publication_statuses: %w[published]
)

expect(result[:project_images].count).to eq(1)
end

it 'returns correct project periods' do
result = query.run_query(start_at: Date.new(2021, 1, 1), end_at: Date.new(2021, 4, 1))
result = query.run_query(
start_at: Date.new(2021, 1, 1),
end_at: Date.new(2021, 4, 1),
publication_statuses: %w[published]
)

expect(result[:periods].count).to eq(2)
expect(result[:periods][@project1.id]).to eq({
'start_at' => Date.new(2021, 2, 1),
Expand All @@ -79,5 +104,41 @@
'end_at' => nil
})
end

context 'when specific publication statuses are requested' do
it 'returns only published projects when only published is requested' do
result = query.run_query(
start_at: nil,
end_at: nil,
publication_statuses: %w[published]
)

expect(result[:projects].count).to eq(4)
expect(result[:projects].pluck(:id)).to match_array [@project1.id, @project2.id, @project3.id, @past_project.id]
end

it 'returns only archived projects when only archived is requested' do
result = query.run_query(
start_at: nil,
end_at: nil,
publication_statuses: %w[archived]
)

expect(result[:projects].count).to eq(1)
expect(result[:projects].first[:id]).to eq(@project5.id)
end

it 'returns expected projects when two publication_statuses are requested' do
result = query.run_query(
start_at: nil,
end_at: nil,
publication_statuses: %w[published archived]
)

expect(result[:projects].count).to eq(5)
expect(result[:projects].pluck(:id))
.to match_array [@project1.id, @project2.id, @project3.id, @project5.id, @past_project.id]
end
end
end
end
2 changes: 1 addition & 1 deletion back/engines/free/email_campaigns/config/locales/nb-NO.yml
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@
content_type:
comments: 'Kommentarer'
content_moderation: 'Moderering av innhold'
events: 'arrangementer'
events: 'Arrangementer'
general: 'Generell'
inputs: 'Innganger'
internal_comments: 'Interne kommentarer'
Expand Down
4 changes: 3 additions & 1 deletion front/app/api/graph_data_units/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ export const useParticipationLive = (
);
};

export const useProjects = (props: ProjectsProps = {}) => {
export const useProjects = (
props: ProjectsProps = { publication_statuses: 'published' }
) => {
return useGraphDataUnits<ProjectsResponse>({
resolved_name: 'ProjectsWidget',
props,
Expand Down
6 changes: 5 additions & 1 deletion front/app/api/graph_data_units/requestTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ interface ParticipationParams extends BaseParams {
props: ParticipationProps;
}

export interface ProjectsProps extends DateProps {}
export type ProjectReportsPublicationStatus = 'published' | 'archived';

export interface ProjectsProps extends DateProps {
publication_statuses: ProjectReportsPublicationStatus;
}

interface ProjectsParams extends BaseParams {
resolved_name: 'ProjectsWidget';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Element } from '@craftjs/core';
import { FormatMessage } from 'typings';

import { useProjects } from 'api/graph_data_units';
import { ProjectReportsPublicationStatus } from 'api/graph_data_units/requestTypes';
import useUserCustomFields from 'api/user_custom_fields/useUserCustomFields';

import useAppConfigurationLocales from 'hooks/useAppConfigurationLocales';
Expand Down Expand Up @@ -42,9 +43,14 @@ import { getCommunity, getComparedDateRange, getProjects } from './utils';
interface Props {
startDate: string;
endDate: string;
publicationStatus?: ProjectReportsPublicationStatus;
}

const PlatformTemplateContent = ({ startDate, endDate }: Props) => {
const PlatformTemplateContent = ({
startDate,
endDate,
publicationStatus = 'published',
}: Props) => {
const dateRange = {
startAt: startDate,
endAt: endDate,
Expand All @@ -70,6 +76,7 @@ const PlatformTemplateContent = ({ startDate, endDate }: Props) => {
const { data: projects } = useProjects({
start_at: startDate,
end_at: endDate,
publication_statuses: publicationStatus,
});

if (!appConfigurationLocales || !userFields || !stats || !projects) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ import { Props } from '../typings';

import ProjectRow from './ProjectRow';

const ProjectsCard = ({ startAt, endAt }: Props) => {
const { data: response } = useProjects({ start_at: startAt, end_at: endAt });
const ProjectsCard = ({
startAt,
endAt,
publicationStatus = 'published',
}: Props) => {
const { data: response } = useProjects({
start_at: startAt,
end_at: endAt,
publication_statuses: publicationStatus,
});
if (!response) return null;

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,53 @@
import React from 'react';

import { Box } from '@citizenlab/cl2-component-library';
import { Box, Select, Text } from '@citizenlab/cl2-component-library';
import { useNode } from '@craftjs/core';
import { IOption } from 'typings';

import { useIntl } from 'utils/cl-intl';

import {
TitleInput,
DateRangeInput,
} from '../ChartWidgets/_shared/ChartWidgetSettings';

import messages from './messages';
import { Props } from './typings';

const Settings = () => {
const { formatMessage } = useIntl();

const {
actions: { setProp },
publicationStatus,
} = useNode((node) => ({
publicationStatus: node.data.props.publicationStatus || 'published',
}));

const handleStatusChange = (option: IOption) => {
setProp((props: Props) => {
props.publicationStatus = option.value;
});
};

const options = [
{ value: 'published', label: formatMessage(messages.published) },
{ value: 'archived', label: formatMessage(messages.archived) },
];

return (
<Box>
<TitleInput />
<Box mb="20px">
<Text variant="bodyM" color="textSecondary" mb="5px">
{formatMessage(messages.publicationStatus)}
</Text>
<Select
options={options}
onChange={handleStatusChange}
value={publicationStatus}
/>
</Box>
<DateRangeInput />
</Box>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ ProjectsWidget.craft = {
title: {},
startAt: undefined,
endAt: undefined,
publicationStatus: undefined,
},
related: {
settings: Settings,
},
};

export const projectsTitle = messages.publishedProjects;
export const projectsTitle = messages.projects;

export default ProjectsWidget;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineMessages } from 'react-intl';

export default defineMessages({
publishedProjects: {
id: 'app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publishedProjects',
defaultMessage: 'Published projects',
projects: {
id: 'app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.projects',
defaultMessage: 'Projects',
},
finished: {
id: 'app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.finished',
Expand All @@ -21,4 +21,16 @@ export default defineMessages({
id: 'app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.planned',
defaultMessage: 'Planned',
},
archived: {
id: 'app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.archived',
defaultMessage: 'Archived',
},
published: {
id: 'app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.published',
defaultMessage: 'Published',
},
publicationStatus: {
id: 'app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publicationStatus',
defaultMessage: 'Publication status',
},
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Multiloc } from 'typings';

import { ProjectReportsPublicationStatus } from 'api/graph_data_units/requestTypes';

export interface Props {
title?: Multiloc;
startAt?: string;
endAt?: string | null;
publicationStatus?: ProjectReportsPublicationStatus;
}
5 changes: 4 additions & 1 deletion front/app/translations/admin/ach-UG.json
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,13 @@
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ChartWidgets.UsersWidget.users": "crwdns2212582:0{numberOfUsers}crwdnd2212582:0{percentageOfUsers}crwdne2212582:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ImageMultiloc.Settings.stretch": "crwdns2201674:0crwdne2201674:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.active": "crwdns2467856:0crwdne2467856:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.archived": "crwdns3094681:0crwdne3094681:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.finished": "crwdns2467858:0crwdne2467858:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.openEnded": "crwdns2504046:0crwdne2504046:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.planned": "crwdns2467860:0crwdne2467860:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publishedProjects": "crwdns2467862:0crwdne2467862:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.projects": "crwdns3094683:0crwdne3094683:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publicationStatus": "crwdns3094685:0crwdne3094685:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.published": "crwdns3094687:0crwdne3094687:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets._shared.missingData": "crwdns1963248:0crwdne1963248:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.noAppropriatePhases": "crwdns1603844:0crwdne1603844:0",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.noPhaseSelected": "crwdns1603846:0crwdne1603846:0",
Expand Down
5 changes: 4 additions & 1 deletion front/app/translations/admin/ar-SA.json
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,13 @@
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ChartWidgets.UsersWidget.users": "المستخدمون: {numberOfUsers} ({percentageOfUsers}%)",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ImageMultiloc.Settings.stretch": "تمتد",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.active": "نشيط",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.archived": "مؤرشفة",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.finished": "انتهى",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.openEnded": "مفتوحة",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.planned": "المخطط لها",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publishedProjects": "المشاريع المنشورة",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.projects": "المشاريع",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publicationStatus": "حالة النشر",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.published": "نُشرت",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets._shared.missingData": "البيانات الخاصة بهذه القطعة مفقودة. أعد تكوينه أو احذفه لتتمكن من حفظ التقرير.",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.noAppropriatePhases": "لم يتم العثور على مراحل مناسبة في هذا المشروع",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.noPhaseSelected": "لم يتم تحديد أي مرحلة. الرجاء تحديد المرحلة أولا.",
Expand Down
5 changes: 4 additions & 1 deletion front/app/translations/admin/cy-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,13 @@
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ChartWidgets.UsersWidget.users": "Users: {numberOfUsers} ({percentageOfUsers}%)",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ImageMultiloc.Settings.stretch": "Ymestyn",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.active": "Actif",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.archived": "Wedi'i archifo",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.finished": "Wedi gorffen",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.openEnded": "Penagored",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.planned": "Wedi'i gynllunio",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publishedProjects": "Prosiectau cyhoeddedig",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.projects": "Prosiectau",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publicationStatus": "Statws cyhoeddi",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.published": "Cyhoeddwyd",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets._shared.missingData": "Mae'r data ar gyfer y teclyn hwn ar goll. Ail-ffurfweddwch neu dilëwch ef i allu cadw'r adroddiad.",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.noAppropriatePhases": "Ni chanfuwyd unrhyw gamau priodol yn y prosiect hwn",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.noPhaseSelected": "Dim cam wedi'i ddewis. Dewiswch gam yn gyntaf.",
Expand Down
5 changes: 4 additions & 1 deletion front/app/translations/admin/da-DK.json
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,13 @@
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ChartWidgets.UsersWidget.users": "Brugere: {numberOfUsers} ({percentageOfUsers}%)",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ImageMultiloc.Settings.stretch": "Stræk",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.active": "Aktiv",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.archived": "Arkiveret",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.finished": "Afsluttet",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.openEnded": "Åbne spørgsmål",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.planned": "Planlagt",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publishedProjects": "Offentliggjorte projekter",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.projects": "Projekter",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.publicationStatus": "Status for offentliggørelse",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.ProjectsWidget.published": "Offentliggjort",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets._shared.missingData": "Dataene for denne widget mangler. Rekonfigurer eller slet den for at kunne gemme rapporten.",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.noAppropriatePhases": "Ingen passende faser fundet i dette projekt",
"app.containers.Admin.reporting.components.ReportBuilder.Widgets.noPhaseSelected": "Ingen fase valgt. Vælg venligst en fase først.",
Expand Down
Loading