Skip to content
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
10 changes: 7 additions & 3 deletions core/scripts/download-work-schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ async def download_work_schedules(
page_size: int,
gateway_cookie: str,
) -> List[Dict]:
url = f"{gateway_url}api/work_schedules/group/{group_id}/?page=$page&{page_size=}"
url = f"{gateway_url}work_schedules/group/{group_id}/?page=$page&{page_size=}"
cookies, connector = make_connector(gateway_cookie)
async with aiohttp.ClientSession(
trust_env=True, raise_for_status=True, cookies=cookies, connector=connector
trust_env=True,
raise_for_status=True,
cookies=cookies,
connector=connector,
headers={"x-osrd-skip-authz": "true"},
) as session:
return await get_paginated(url, session)

Expand All @@ -29,7 +33,7 @@ async def download_work_schedules(
Downloads a full work schedule group.
"""
)
@click.option("--gateway-url", "-u", default="https://demo.osrd.fr/")
@click.option("--gateway-url", "-u", default="https://demo.osrd.fr/api/")
@click.option("--group-id", "-g", required=True, type=int)
@click.option("--path", "-p", default="work_schedules.json")
@click.option("--gateway-cookie", "-c", envvar="GATEWAY_COOKIE")
Expand Down
12 changes: 0 additions & 12 deletions editoast/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions editoast/src/views/operational_studies/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pub mod project;
pub mod scenario;
pub mod study;

use models::WorkSchedule;
use models::prelude::*;
use models::project::Project;
use models::scenario::Scenario;
Expand Down Expand Up @@ -60,12 +59,4 @@ impl Ordering {
Ordering::LastModifiedDesc => Scenario::LAST_MODIFICATION.desc(),
}
}

pub fn as_work_schedule_ordering(&self) -> SortSetting<WorkSchedule> {
match *self {
Ordering::NameAsc => WorkSchedule::OBJ_ID.asc(),
Ordering::NameDesc => WorkSchedule::OBJ_ID.desc(),
_ => WorkSchedule::OBJ_ID.asc(),
}
}
}
15 changes: 2 additions & 13 deletions editoast/src/views/work_schedules.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::pagination::PaginatedList;
use crate::error::Result;
use crate::views::operational_studies::hierarchy::Ordering;
use crate::views::pagination::PaginationQueryParams;
use crate::views::pagination::PaginationStats;
use crate::views::path::projection::Intersection;
Expand Down Expand Up @@ -391,19 +390,11 @@ pub(in crate::views) struct GroupContentResponse {
stats: PaginationStats,
}

#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
#[into_params(parameter_in = Query)]
pub struct WorkScheduleOrderingParam {
#[serde(default)]
#[param(inline)]
pub ordering: Ordering, // FIXME: use a dedicated enum, that one is for projects/studies/scenarios and has superfluous variants
}

#[editoast_derive::route]
#[utoipa::path(
get, path = "",
tag = "work_schedules",
params(PaginationQueryParams<100>, WorkScheduleGroupIdParam, WorkScheduleOrderingParam),
params(PaginationQueryParams<100>, WorkScheduleGroupIdParam),
responses(
(status = 200, description = "The work schedules in the group", body = inline(GroupContentResponse)),
(status = 404, description = "Work schedule group not found"),
Expand All @@ -413,13 +404,11 @@ pub(in crate::views) async fn get_group(
State(db_pool): State<Arc<DbConnectionPoolV2>>,
Path(WorkScheduleGroupIdParam { id: group_id }): Path<WorkScheduleGroupIdParam>,
Query(pagination_params): Query<PaginationQueryParams<100>>,
Query(ordering_params): Query<WorkScheduleOrderingParam>,
) -> Result<Json<GroupContentResponse>> {
let ordering = ordering_params.ordering;
let settings = pagination_params
.into_selection_settings()
.filter(move || WorkSchedule::WORK_SCHEDULE_GROUP_ID.eq(group_id))
.order_by(move || ordering.as_work_schedule_ordering());
.order_by(move || WorkSchedule::ID.asc());

let conn = &mut db_pool.get().await?;

Expand Down
8 changes: 0 additions & 8 deletions front/src/common/api/generatedEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,6 @@ const injectedRtkApi = api
params: {
page: queryArg.page,
page_size: queryArg.pageSize,
ordering: queryArg.ordering,
},
}),
providesTags: ['work_schedules'],
Expand Down Expand Up @@ -2943,13 +2942,6 @@ export type GetWorkSchedulesGroupByIdApiArg = {
pageSize?: number;
/** A work schedule group ID */
id: number;
ordering?:
| 'NameAsc'
| 'NameDesc'
| 'CreationDateAsc'
| 'CreationDateDesc'
| 'LastModifiedDesc'
| 'LastModifiedAsc';
};
export type PutWorkSchedulesGroupByIdApiResponse =
/** status 200 The work schedules have been created */ WorkSchedule[];
Expand Down
Loading