Repository: risingwavelabs/risingwave
File: src/meta/src/manager/diagnose.rs (Rust)

Code before:
        match LicenseManager::get().license() {
            Ok(license) => {
                let fmt_option = |value: Option<u64>| match value {
                    Some(v) => v.to_string(),
                    None => "unlimited".to_owned(),
                };

                let expires_at = if license.exp == u64::MAX {
                    "never".to_owned()
                } else if license.exp > i64::MAX as u64 {
                    format!("invalid ({})", license.exp)
                } else {
                    let exp_i64 = license.exp as i64;
                    chrono::DateTime::<chrono::Utc>::from_timestamp(exp_i64, 0)
                        .map(|ts| ts.to_rfc3339())
                        .unwrap_or_else(|| format!("invalid ({})", license.exp))
                };

                let mut row = Row::new();
                row.add_cell("status".into());
                row.add_cell("valid".into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("tier".into());
                row.add_cell(format!("{:?}", license.tier).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("expires_at".into());
                row.add_cell(expires_at.into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("rwu_limit".into());
                row.add_cell(fmt_option(license.rwu_limit.map(|v| v.get())).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("cpu_core_limit".into());
                row.add_cell(fmt_option(license.cpu_core_limit()).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("memory_limit_bytes".into());
                row.add_cell(fmt_option(license.memory_limit()).into());
                table.add_row(row);

                let mut features: Vec<_> = license
                    .tier
                    .available_features()

Review comment (bug):
Using the debug repr might be verbose. Given that we already have the "feature_summary" row, shall we add a `fn name` to `Tier` to only obtain the tier name, like

- free
- paid
- all
- `<custom name>`

Code after:
        match LicenseManager::get().license() {
            Ok(license) => {
                let fmt_option = |value: Option<u64>| match value {
                    Some(v) => v.to_string(),
                    None => "unlimited".to_owned(),
                };

                let expires_at = if license.exp == u64::MAX {
                    "never".to_owned()
                } else {
                    let exp_i64 = license.exp as i64;
                    chrono::DateTime::<chrono::Utc>::from_timestamp(exp_i64, 0)
                        .map(|ts| ts.to_rfc3339())
                        .unwrap_or_else(|| format!("invalid ({})", license.exp))
                };

                let mut row = Row::new();
                row.add_cell("status".into());
                row.add_cell("valid".into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("tier".into());
                row.add_cell(license.tier.name().into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("expires_at".into());
                row.add_cell(expires_at.into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("rwu_limit".into());
                row.add_cell(fmt_option(license.rwu_limit.map(|v| v.get())).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("cpu_core_limit".into());
                row.add_cell(fmt_option(license.cpu_core_limit()).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("memory_limit_bytes".into());
                row.add_cell(fmt_option(license.memory_limit()).into());
                table.add_row(row);

                let mut features: Vec<_> = license
                    .tier
                    .available_features()
                    .map(|f| f.name())
                    .collect();