Skip to content

badges: Remove obsolete data structures #5429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/models.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub use self::action::{insert_version_owner_action, VersionAction, VersionOwnerAction};
pub use self::badge::{Badge, CrateBadge, MaintenanceStatus};
pub use self::category::{Category, CrateCategory, NewCategory};
pub use self::crate_owner_invitation::{CrateOwnerInvitation, NewCrateOwnerInvitationOutcome};
pub use self::dependency::{Dependency, DependencyKind, ReverseDependency};
Expand All @@ -18,7 +17,6 @@ pub use self::version::{NewVersion, TopVersions, Version};
pub mod helpers;

mod action;
mod badge;
pub mod category;
mod crate_owner_invitation;
pub mod dependency;
Expand Down
147 changes: 0 additions & 147 deletions src/models/badge.rs

This file was deleted.

24 changes: 5 additions & 19 deletions src/views.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use chrono::NaiveDateTime;
use std::collections::HashMap;
use url::Url;

use crate::github;
use crate::models::{
Badge, Category, Crate, CrateOwnerInvitation, CreatedApiToken, Dependency, DependencyKind,
Keyword, Owner, ReverseDependency, Team, TopVersions, User, Version, VersionDownload,
Category, Crate, CrateOwnerInvitation, CreatedApiToken, Dependency, DependencyKind, Keyword,
Owner, ReverseDependency, Team, TopVersions, User, Version, VersionDownload,
VersionOwnerAction,
};
use crate::util::rfc3339;
Expand All @@ -14,19 +13,6 @@ use crate::util::rfc3339;
/// and are possibly of malicious intent e.g. ad tracking networks, etc.
const DOCUMENTATION_BLOCKLIST: &[&str] = &["rust-ci.org", "rustless.org", "ironframework.io"];

#[derive(PartialEq, Eq, Debug, Serialize, Deserialize)]
pub struct EncodableBadge {
pub badge_type: String,
pub attributes: HashMap<String, Option<String>>,
}

impl From<Badge> for EncodableBadge {
fn from(badge: Badge) -> Self {
// The serde attributes on Badge ensure it can be deserialized to EncodableBadge
serde_json::from_value(serde_json::to_value(badge).unwrap()).unwrap()
}
}

#[derive(Serialize, Deserialize, Debug)]
pub struct EncodableCategory {
pub id: String,
Expand Down Expand Up @@ -216,7 +202,7 @@ pub struct EncodableCrate {
pub versions: Option<Vec<i32>>,
pub keywords: Option<Vec<String>>,
pub categories: Option<Vec<String>>,
pub badges: Option<Vec<EncodableBadge>>,
pub badges: Option<Vec<()>>,
#[serde(with = "rfc3339")]
pub created_at: NaiveDateTime,
// NOTE: Used by shields.io, altering `downloads` requires a PR with shields.io
Expand All @@ -242,7 +228,7 @@ impl EncodableCrate {
versions: Option<Vec<i32>>,
keywords: Option<&[Keyword]>,
categories: Option<&[Category]>,
badges: Option<Vec<Badge>>,
badges: Option<Vec<()>>,
exact_match: bool,
recent_downloads: Option<i64>,
) -> Self {
Expand Down Expand Up @@ -313,7 +299,7 @@ impl EncodableCrate {
pub fn from_minimal(
krate: Crate,
top_versions: Option<&TopVersions>,
badges: Option<Vec<Badge>>,
badges: Option<Vec<()>>,
exact_match: bool,
recent_downloads: Option<i64>,
) -> Self {
Expand Down