mirror of
https://github.com/acemod/arma3-wiki.git
synced 2025-12-22 05:37:06 +00:00
add hash, various cleanup
This commit is contained in:
791
Cargo.lock
generated
791
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -8,10 +8,10 @@ members = [
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
serde = "1.0.219"
|
||||
serde_json = "1.0.140"
|
||||
serde = "1.0.228"
|
||||
serde_json = "1.0.145"
|
||||
serde_yaml = { version = "0.9.34-deprecated" }
|
||||
tokio = "1.45.1"
|
||||
tokio = "1.48.0"
|
||||
urlencoding = "2.1.3"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
|
||||
@@ -65,7 +65,7 @@ impl Issues {
|
||||
return Ok(Some(issue.clone()));
|
||||
}
|
||||
let rate = self.rate.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
if rate != 0 && rate % 20 == 0 {
|
||||
if rate != 0 && rate.is_multiple_of(20) {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(RATE_SLEEP)).await;
|
||||
}
|
||||
gh.as_ref()
|
||||
@@ -78,7 +78,7 @@ impl Issues {
|
||||
.map_err(|e| e.to_string())
|
||||
} else {
|
||||
let rate = self.rate.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
if rate != 0 && rate % 20 == 0 {
|
||||
if rate != 0 && rate.is_multiple_of(20) {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
|
||||
}
|
||||
gh.as_ref()
|
||||
@@ -100,7 +100,7 @@ impl Issues {
|
||||
let title = format!("Parse Failed: {command}");
|
||||
if let Some(issue) = self.issues.iter().find(|i| i.title == title) {
|
||||
let rate = self.rate.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
if rate != 0 && rate % 20 == 0 {
|
||||
if rate != 0 && rate.is_multiple_of(20) {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(RATE_SLEEP)).await;
|
||||
}
|
||||
gh.as_ref()
|
||||
@@ -133,7 +133,7 @@ impl Issues {
|
||||
return Ok(Some(issue.clone()));
|
||||
}
|
||||
let rate = self.rate.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
if rate != 0 && rate % 20 == 0 {
|
||||
if rate != 0 && rate.is_multiple_of(20) {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(RATE_SLEEP)).await;
|
||||
}
|
||||
gh.as_ref()
|
||||
@@ -146,7 +146,7 @@ impl Issues {
|
||||
.map_err(|e| e.to_string())
|
||||
} else {
|
||||
let rate = self.rate.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
if rate != 0 && rate % 20 == 0 {
|
||||
if rate != 0 && rate.is_multiple_of(20) {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
|
||||
}
|
||||
gh.as_ref()
|
||||
@@ -169,7 +169,7 @@ impl Issues {
|
||||
let title = format!("Parse Failed: {ns}::{handler}");
|
||||
if let Some(issue) = self.issues.iter().find(|i| i.title == title) {
|
||||
let rate = self.rate.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
if rate != 0 && rate % 20 == 0 {
|
||||
if rate != 0 && rate.is_multiple_of(20) {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(RATE_SLEEP)).await;
|
||||
}
|
||||
gh.as_ref()
|
||||
|
||||
@@ -6,7 +6,7 @@ use reqwest::Client;
|
||||
|
||||
use crate::WafSkip;
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[allow(clippy::too_many_lines, clippy::cognitive_complexity)]
|
||||
pub async fn event_handlers(
|
||||
client: &Client,
|
||||
report: &mut Report,
|
||||
@@ -258,11 +258,15 @@ async fn subsection(
|
||||
content
|
||||
};
|
||||
|
||||
if get_from.is_some() {
|
||||
body = body.split_once(&get_from.unwrap()).unwrap().1.to_owned();
|
||||
if let Some(from) = get_from {
|
||||
if let Some((_, rest)) = body.split_once(&from) {
|
||||
body = rest.to_owned();
|
||||
}
|
||||
}
|
||||
if get_to.is_some() {
|
||||
body = body.split_once(&get_to.unwrap()).unwrap().0.to_owned();
|
||||
if let Some(to) = get_to {
|
||||
if let Some((rest, _)) = body.split_once(&to) {
|
||||
body = rest.to_owned();
|
||||
}
|
||||
}
|
||||
|
||||
let mut event_handlers = Vec::new();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "arma3-wiki"
|
||||
description = "A project to store data about Arma 3 commands in a useable format"
|
||||
license = "MIT"
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
edition = "2024"
|
||||
|
||||
[lints]
|
||||
|
||||
@@ -269,16 +269,14 @@ impl Wiki {
|
||||
}
|
||||
|
||||
fn recently_updated(path: &std::path::Path) -> bool {
|
||||
if let Ok(timestamp) = std::fs::read_to_string(path.join("last-update.timestamp")) {
|
||||
if let Ok(timestamp) = timestamp.parse::<u64>() {
|
||||
if let Ok(elapsed) = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.map(|t| t.as_secs())
|
||||
{
|
||||
// Update every 6 hours
|
||||
return elapsed - timestamp < 60 * 60 * 6;
|
||||
}
|
||||
}
|
||||
if let Ok(timestamp) = std::fs::read_to_string(path.join("last-update.timestamp"))
|
||||
&& let Ok(timestamp) = timestamp.parse::<u64>()
|
||||
&& let Ok(elapsed) = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.map(|t| t.as_secs())
|
||||
{
|
||||
// Update every 6 hours
|
||||
return elapsed - timestamp < 60 * 60 * 6;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use super::{Locality, Param, Since, Version};
|
||||
use super::{Locality, Param, Since};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum EventHandler {
|
||||
@@ -116,6 +116,8 @@ impl ParsedEventHandler {
|
||||
|
||||
#[cfg(feature = "wiki")]
|
||||
fn id_from_arg_title(source: &str) -> Result<(String, Option<Since>), String> {
|
||||
use crate::model::Version;
|
||||
|
||||
let source = if source.contains(" ") {
|
||||
source.split_once(" ").unwrap().0
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Version;
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Default, Hash, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Since {
|
||||
#[serde(default)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
||||
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Since;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ArraySizedElement {
|
||||
pub name: String,
|
||||
pub value: Value,
|
||||
@@ -13,7 +13,7 @@ pub struct ArraySizedElement {
|
||||
pub since: Option<Since>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Value {
|
||||
Anything,
|
||||
ArraySized {
|
||||
@@ -23,7 +23,7 @@ pub enum Value {
|
||||
ArrayUnknown,
|
||||
ArrayUnsized {
|
||||
#[serde(rename = "type")]
|
||||
typ: Box<Value>,
|
||||
typ: Box<Self>,
|
||||
desc: String,
|
||||
},
|
||||
ArrayDate,
|
||||
@@ -75,7 +75,7 @@ pub enum Value {
|
||||
|
||||
Unknown,
|
||||
|
||||
OneOf(Vec<(Value, Option<Since>)>),
|
||||
OneOf(Vec<(Self, Option<Since>)>),
|
||||
}
|
||||
|
||||
// regex once cell
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Version {
|
||||
major: u8,
|
||||
minor: u8,
|
||||
@@ -68,12 +68,6 @@ impl std::fmt::Display for Version {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::PartialEq for Version {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.major == other.major && self.minor == other.minor
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::PartialOrd for Version {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
if self.major == other.major {
|
||||
|
||||
Reference in New Issue
Block a user