Admins use analysis units and questions too
They add their own units on the admin page when they need more, and testing shows the same balance as users see. Regenerating and prompt previews stay free. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -9,7 +9,6 @@ use axum::Json;
|
||||
use axum::extract::{Path, State};
|
||||
use axum::http::StatusCode;
|
||||
use axum_extra::extract::WithRejection;
|
||||
use db::Role;
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Value, json};
|
||||
use sqlx::PgPool;
|
||||
@@ -145,7 +144,6 @@ pub async fn ask(
|
||||
));
|
||||
}
|
||||
|
||||
let admin = auth.user.has_role(Role::Admin);
|
||||
let (model, fallback, prompt_version) = model_and_version(&state, &analysis.language).await?;
|
||||
let question_id = Uuid::now_v7();
|
||||
let mut tx = state.db.begin().await?;
|
||||
@@ -161,13 +159,12 @@ pub async fn ask(
|
||||
.bind(&analysis.language)
|
||||
.bind(&model)
|
||||
.bind(&prompt_version)
|
||||
.bind(i32::from(!admin))
|
||||
.bind(1i32)
|
||||
.bind(&fallback)
|
||||
.fetch_one(&mut *tx)
|
||||
.await?;
|
||||
if !admin {
|
||||
credits::spend_question(&mut tx, auth.id(), question_id).await?;
|
||||
}
|
||||
// Admins use questions too (they can add more on the admin page).
|
||||
credits::spend_question(&mut tx, auth.id(), question_id).await?;
|
||||
tx.commit().await?;
|
||||
Ok((StatusCode::ACCEPTED, Json(row.view())))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user