captcha stats

This commit is contained in:
realaravinth
2021-05-27 14:47:29 +05:30
parent df89938f2a
commit fcdbe66b26
28 changed files with 412 additions and 122 deletions

View File

@@ -15,11 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use crate::PAGES;
use actix_web::{HttpResponse, Responder};
use lazy_static::lazy_static;
use sailfish::TemplateOnce;
use my_codegen::get;
use crate::PAGES;
use sailfish::TemplateOnce;
#[derive(Clone, TemplateOnce)]
#[template(path = "auth/login/index.html")]
@@ -37,7 +37,7 @@ lazy_static! {
static ref INDEX: String = IndexPage::default().render_once().unwrap();
}
#[get(path="PAGES.auth.login")]
#[get(path = "PAGES.auth.login")]
pub async fn login() -> impl Responder {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")

View File

@@ -11,9 +11,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */
use actix_web::{web, HttpResponse, Responder};
use lazy_static::lazy_static;

View File

@@ -17,9 +17,11 @@
use actix_identity::Identity;
use actix_web::{web, HttpResponse, Responder};
use futures::{future::TryFutureExt, try_join};
use sailfish::TemplateOnce;
use crate::errors::*;
use crate::stats::fetch::Stats;
use crate::Data;
const PAGE: &str = "SiteKeys";
@@ -75,13 +77,19 @@ pub async fn view_sitekey(
.fetch_one(&data.db)
.await?;
let levels = sqlx::query_as!(
let levels_fut = sqlx::query_as!(
Level,
"SELECT difficulty_factor, visitor_threshold from mcaptcha_levels WHERE config_id = $1",
"SELECT
difficulty_factor, visitor_threshold
FROM
mcaptcha_levels
WHERE config_id = $1",
&config.config_id
)
.fetch_all(&data.db)
.await?;
.err_into();
let (stats, levels) = try_join!(Stats::new(&key, &data.db), levels_fut)?;
let body = IndexPage::new(config, levels).render_once().unwrap();
Ok(HttpResponse::Ok()