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

editoast: endpoints to retrieve stdcm payloads #10212

Merged
merged 1 commit into from
Jan 17, 2025
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 editoast/editoast_authz/src/authorizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ impl<S: StorageDriver> Authorizer<S> {
self.user_roles.contains(&S::BuiltinRole::superuser())
}

pub fn is_superuser_stub(&self) -> bool {
self.user_roles.contains(&S::BuiltinRole::superuser()) && self.user_id == -1
}

/// Returns whether a user with some id exists
#[tracing::instrument(skip_all, fields(user_id = %user_id), ret(level = Level::DEBUG), err)]
pub async fn user_exists(&self, user_id: i64) -> Result<bool, S::Error> {
Expand Down
3 changes: 2 additions & 1 deletion editoast/editoast_common/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ pub struct TracingConfig {

pub fn create_tracing_subscriber<T: SpanExporter + 'static>(
tracing_config: TracingConfig,
log_level: tracing_subscriber::filter::LevelFilter,
exporter: T,
) -> impl tracing::Subscriber {
let env_filter_layer = tracing_subscriber::EnvFilter::builder()
// Set the default log level to 'info'
.with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into())
.with_default_directive(log_level.into())
.from_env_lossy();
let fmt_layer = tracing_subscriber::fmt::layer()
.pretty()
Expand Down
2 changes: 1 addition & 1 deletion editoast/editoast_models/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ diesel::table! {
stdcm_logs (id) {
id -> Int8,
#[max_length = 32]
trace_id -> Varchar,
trace_id -> Nullable<Varchar>,
request -> Jsonb,
response -> Jsonb,
created -> Timestamptz,
Expand Down
2 changes: 1 addition & 1 deletion editoast/editoast_schemas/src/train_schedule/margins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<'de> Deserialize<'de> for Margins {
}
}

#[derive(Debug, Copy, Clone, PartialEq, Derivative)]
#[derive(Debug, Copy, Clone, PartialEq, Derivative, ToSchema)]
#[derivative(Hash, Default)]
pub enum MarginValue {
#[derivative(Default)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP INDEX IF EXISTS stdcm_logs_trace_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX IF NOT EXISTS stdcm_logs_trace_id ON stdcm_logs (trace_id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
UPDATE stdcm_logs
SET trace_id = REPLACE(gen_random_uuid()::text, '-', '')
WHERE trace_id IS NULL;

ALTER TABLE stdcm_logs ALTER COLUMN trace_id SET NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE stdcm_logs ALTER COLUMN trace_id DROP NOT NULL;
Loading
Loading