Skip to content

Commit

Permalink
editoast: endpoints to retrieve stdcm payloads
Browse files Browse the repository at this point in the history
Signed-off-by: hamz2a <atrari.hamza@gmail.com>
  • Loading branch information
hamz2a committed Jan 16, 2025
1 parent c806a2f commit c520cf9
Show file tree
Hide file tree
Showing 23 changed files with 1,265 additions and 380 deletions.
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

0 comments on commit c520cf9

Please sign in to comment.