Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
OG
Browse files Browse the repository at this point in the history
sorry clippy

stop testing on nightly

switch rust-toolchain over to stable

no behaviour changes, minor meaningful code changes, but a bunch
of formatting changes because we were using nightly-only rustfmt
options.

resovles #228

bump rust-toolchain to nightly-2020-02-21
  • Loading branch information
jeremyBanks authored and deploy committed Feb 22, 2020
2 parents 550bc51 + 67387d6 commit e9627b2
Show file tree
Hide file tree
Showing 20 changed files with 280 additions and 279 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ jobs:
with:
node-version: 13.x

- name: setup - install rust nightly
- name: setup - install rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: stable

- name: setup - recall published version
uses: actions/download-artifact@v1
Expand All @@ -152,7 +152,7 @@ jobs:
chmod +x speedruns-linux-x86_64
./speedruns-linux-x86_64 --help
cargo +nightly install speedruns --version $version
cargo install speedruns --version $version
speedruns --help
npm install -g speedruns@$version
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2020-02-05
stable
11 changes: 0 additions & 11 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
comment_width = 92
format_code_in_doc_comments = true
inline_attribute_width = 64
match_arm_blocks = false
max_width = 92
merge_imports = true
newline_style = "Unix"
reorder_impl_items = true
struct_field_align_threshold = 64
trailing_semicolon = false
unstable_features = true
use_field_init_shorthand = true
wrap_comments = true
normalize_doc_attributes = true
2 changes: 1 addition & 1 deletion scripts/fix.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -euxo pipefail
tslint --fix --project . || echo "tslint failed"

cargo fix --workspace --allow-dirty --allow-staged -Z unstable-options --clippy
cargo fix --workspace --allow-dirty --allow-staged
16 changes: 9 additions & 7 deletions src/bin/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use std::{

use flate2::read::GzDecoder;
use itertools::Itertools;
#[allow(unused)] use log::{debug, error, info, trace, warn};
#[allow(unused)]
use log::{debug, error, info, trace, warn};
use serde::{de::DeserializeOwned, Serialize};
use serde_json::{Deserializer as JsonDeserializer, Value as JsonValue};
use tempfile::NamedTempFile;
Expand Down Expand Up @@ -59,7 +60,7 @@ pub fn main(args: Args) -> Result<(), Box<dyn std::error::Error>> {
for api_game in load_api_type::<api::Game>("data/api/games.jsonl.gz")? {
if args.fixtures && !fixture_game_slugs.contains(&api_game.abbreviation().as_ref())
{
continue
continue;
} else {
fixture_game_ids.insert(api_game.id().clone());
}
Expand All @@ -76,7 +77,7 @@ pub fn main(args: Args) -> Result<(), Box<dyn std::error::Error>> {
info!("Loading API runs...");
for api_run in load_api_type::<api::Run>("data/api/runs.jsonl.gz")? {
if args.fixtures && !fixture_game_ids.contains(api_run.game()) {
continue
continue;
} else {
fixture_run_ids.insert(api_run.id().clone());
for player in api_run.players() {
Expand All @@ -97,7 +98,7 @@ pub fn main(args: Args) -> Result<(), Box<dyn std::error::Error>> {
info!("Loading API users...");
for api_user in load_api_type::<api::User>("data/api/users.jsonl.gz")? {
if args.fixtures && !fixture_user_ids.contains(api_user.id()) {
continue
continue;
}

let user = api_user
Expand All @@ -120,7 +121,7 @@ pub fn main(args: Args) -> Result<(), Box<dyn std::error::Error>> {
)))) {
Ok(_) => {
info!("Database validation successful.");
break
break;
}
Err(errors) => {
error!("Database validation failed: {}", errors);
Expand All @@ -142,8 +143,9 @@ pub fn main(args: Args) -> Result<(), Box<dyn std::error::Error>> {
User(user) => dead_user_ids.insert(*user.id()),
Game(game) => dead_game_ids.insert(*game.id()),
Level(level) => dead_level_ids.insert(*level.id()),
Category(category) =>
dead_category_ids.insert(*category.id()),
Category(category) => {
dead_category_ids.insert(*category.id())
}
};
}
IntegrityError::CheckFailed { .. } => {
Expand Down
17 changes: 9 additions & 8 deletions src/bin/scrape.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![allow(clippy::useless_attribute, clippy::useless_vec)]

use flate2::{read::GzDecoder, write::GzEncoder};
#[allow(unused)] use log::{debug, error, info, trace, warn};
#[allow(unused)]
use log::{debug, error, info, trace, warn};
use serde_json::{Deserializer as JsonDeserializer, Value as JsonValue};
use std::{
collections::BTreeMap,
Expand All @@ -12,7 +13,7 @@ use tempfile::NamedTempFile;

#[derive(PartialEq, Eq, Hash)]
struct Resource {
id: &'static str,
id: &'static str,
order: &'static str,
embed: &'static str,
}
Expand All @@ -39,7 +40,7 @@ const RESOURCES: [Resource; 3] = [
struct Spider {
games_by_id: BTreeMap<String, JsonValue>,
users_by_id: BTreeMap<String, JsonValue>,
runs_by_id: BTreeMap<String, JsonValue>,
runs_by_id: BTreeMap<String, JsonValue>,
}

impl Spider {
Expand Down Expand Up @@ -173,18 +174,18 @@ impl Spider {
Ok(mut response) => match response.json::<JsonValue>() {
Ok(response) => {
response_data = response;
break
break;
}
Err(error) => {
error!("response error: {:?}", error);
std::thread::sleep(std::time::Duration::from_secs(32));
continue
continue;
}
},
Err(error) => {
error!("request error: {:?}", error);
std::thread::sleep(std::time::Duration::from_secs(32));
continue
continue;
}
}
}
Expand Down Expand Up @@ -212,11 +213,11 @@ impl Spider {
if from_start {
if self.resource_by_id(resource).len() == previous {
// no new items at beginning of list
break
break;
}
} else if items.len() < 200 {
// end of entire run list
break
break;
};

// save progress
Expand Down
7 changes: 4 additions & 3 deletions src/bin/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use actix_web::{self, middleware, web, HttpResponse};

use juniper::{self, http::GraphQLRequest};
use lazy_static::lazy_static;
#[allow(unused)] use log::{debug, error, info, trace, warn};
#[allow(unused)]
use log::{debug, error, info, trace, warn};
use serde::de::DeserializeOwned;
use serde_json::{Deserializer as JsonDeserializer, Value as JsonValue};
use speedruns::data::{
Expand Down Expand Up @@ -81,7 +82,7 @@ async fn diediedie() -> HttpResponse {
pub struct Args {
/// port to run server on
#[argh(option)]
port: Option<u32>,
port: Option<u32>,
/// whether to skip the database import (such as if you only need to run the server to
/// briefly download the schema)
#[argh(switch)]
Expand Down Expand Up @@ -120,7 +121,7 @@ fn unpack_tables() -> Tables {
if let crate::Subcommand::Serve(args) = args.subcommand {
if args.no_data {
info!("Skipping database import, will run with no data!");
return Tables::new(vec![], vec![], vec![], vec![], vec![])
return Tables::new(vec![], vec![], vec![], vec![], vec![]);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/bin/speedruns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

use std::error::Error;

#[allow(unused)] use log::{debug, error, info, trace, warn};
#[allow(unused)]
use log::{debug, error, info, trace, warn};

mod import;
mod scrape;
Expand Down
57 changes: 29 additions & 28 deletions src/lib/api/normalize.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use derive_more::From;
use err_derive::Error;
use lazy_static::lazy_static;
#[allow(unused)] use log::{debug, error, info, trace, warn};
#[allow(unused)]
use log::{debug, error, info, trace, warn};
use regex::Regex;
use validator::Validate;

Expand Down Expand Up @@ -54,17 +55,17 @@ impl Normalize for api::Names {
fn normalize(&self) -> Result<Self::Normalized, Error> {
if let Some(name) = self.international() {
if !name.is_empty() {
return Ok(name.to_string())
return Ok(name.to_string());
}
}
if let Some(name) = self.international() {
if !name.is_empty() {
return Ok(name.to_string())
return Ok(name.to_string());
}
}
if let Some(name) = self.japanese() {
if !name.is_empty() {
return Ok(name.to_string())
return Ok(name.to_string());
}
}
Err(Error::NoNames)
Expand All @@ -76,11 +77,11 @@ impl Normalize for api::Game {

fn normalize(&self) -> Result<Self::Normalized, Error> {
let game = Game {
id: u64_from_base36(self.id())?,
name: self.names().normalize()?,
slug: slugify(self.abbreviation()),
src_slug: self.abbreviation().to_string(),
created: *self.created(),
id: u64_from_base36(self.id())?,
name: self.names().normalize()?,
slug: slugify(self.abbreviation()),
src_slug: self.abbreviation().to_string(),
created: *self.created(),
primary_timing: self.ruleset().default_time().normalize()?,
};
game.validate()?;
Expand All @@ -91,11 +92,11 @@ impl Normalize for api::Game {
.map(|api_category| -> Result<Category, Error> {
let category = Category {
game_id: u64_from_base36(self.id())?,
id: u64_from_base36(api_category.id())?,
slug: slugify(api_category.name()),
name: api_category.name().to_string(),
rules: api_category.rules().clone().unwrap_or_else(String::new),
per: api_category.type_().normalize()?,
id: u64_from_base36(api_category.id())?,
slug: slugify(api_category.name()),
name: api_category.name().to_string(),
rules: api_category.rules().clone().unwrap_or_else(String::new),
per: api_category.type_().normalize()?,
};

category.validate()?;
Expand All @@ -110,10 +111,10 @@ impl Normalize for api::Game {
.map(|api_level| -> Result<Level, Error> {
let level = Level {
game_id: u64_from_base36(self.id())?,
id: u64_from_base36(api_level.id())?,
slug: slugify(api_level.name()),
name: api_level.name().to_string(),
rules: api_level.rules().clone().unwrap_or_default(),
id: u64_from_base36(api_level.id())?,
slug: slugify(api_level.name()),
name: api_level.name().to_string(),
rules: api_level.rules().clone().unwrap_or_default(),
};

level.validate()?;
Expand All @@ -134,23 +135,23 @@ impl Normalize for api::Run {
match self.status() {
api::RunStatus::Verified { .. } => {
let run = Run {
game_id: u64_from_base36(self.game())?,
id: u64_from_base36(self.id())?,
created: *self.submitted(),
date: *self.date(),
game_id: u64_from_base36(self.game())?,
id: u64_from_base36(self.id())?,
created: *self.submitted(),
date: *self.date(),
category_id: u64_from_base36(self.category())?,
level_id: match self.level() {
level_id: match self.level() {
None => None,
Some(level_id) => Some(u64_from_base36(level_id)?),
},
times_ms: self.times().normalize()?,
players: self
times_ms: self.times().normalize()?,
players: self
.players()
.iter()
.map(Normalize::normalize)
.map(Result::unwrap)
.collect(),
videos: self
videos: self
.videos()
.as_ref()
.map(|video| {
Expand Down Expand Up @@ -254,8 +255,8 @@ impl Normalize for api::RunTimes {
}

Ok(RunTimesMs {
igt: self.ingame().as_ref().map(|s| parse_duration_ms(s)),
rta: self.realtime().as_ref().map(|s| parse_duration_ms(s)),
igt: self.ingame().as_ref().map(|s| parse_duration_ms(s)),
rta: self.realtime().as_ref().map(|s| parse_duration_ms(s)),
rta_nl: self
.realtime_noloads()
.as_ref()
Expand Down
Loading

1 comment on commit e9627b2

@vercel
Copy link

@vercel vercel bot commented on e9627b2 Feb 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.