@@ -5,9 +5,8 @@ use diesel::prelude::*;
5
5
6
6
use crate :: util:: errors:: { cargo_err, AppResult } ;
7
7
8
- use crate :: models:: { Crate , Dependency , User , VersionOwnerAction } ;
8
+ use crate :: models:: { Crate , Dependency , User } ;
9
9
use crate :: schema:: * ;
10
- use crate :: views:: { EncodableAuditAction , EncodableVersion , EncodableVersionLinks } ;
11
10
12
11
// Queryable has a custom implementation below
13
12
#[ derive( Clone , Identifiable , Associations , Debug , Queryable , Deserialize , Serialize ) ]
@@ -80,55 +79,6 @@ impl TopVersions {
80
79
}
81
80
82
81
impl Version {
83
- pub fn encodable (
84
- self ,
85
- crate_name : & str ,
86
- published_by : Option < User > ,
87
- audit_actions : Vec < ( VersionOwnerAction , User ) > ,
88
- ) -> EncodableVersion {
89
- let Version {
90
- id,
91
- num,
92
- updated_at,
93
- created_at,
94
- downloads,
95
- features,
96
- yanked,
97
- license,
98
- crate_size,
99
- ..
100
- } = self ;
101
- let num = num. to_string ( ) ;
102
- EncodableVersion {
103
- dl_path : format ! ( "/api/v1/crates/{}/{}/download" , crate_name, num) ,
104
- readme_path : format ! ( "/api/v1/crates/{}/{}/readme" , crate_name, num) ,
105
- num : num. clone ( ) ,
106
- id,
107
- krate : crate_name. to_string ( ) ,
108
- updated_at,
109
- created_at,
110
- downloads,
111
- features,
112
- yanked,
113
- license,
114
- links : EncodableVersionLinks {
115
- dependencies : format ! ( "/api/v1/crates/{}/{}/dependencies" , crate_name, num) ,
116
- version_downloads : format ! ( "/api/v1/crates/{}/{}/downloads" , crate_name, num) ,
117
- authors : format ! ( "/api/v1/crates/{}/{}/authors" , crate_name, num) ,
118
- } ,
119
- crate_size,
120
- published_by : published_by. map ( User :: into) ,
121
- audit_actions : audit_actions
122
- . into_iter ( )
123
- . map ( |( audit_action, user) | EncodableAuditAction {
124
- action : audit_action. action . into ( ) ,
125
- user : user. into ( ) ,
126
- time : audit_action. time ,
127
- } )
128
- . collect ( ) ,
129
- }
130
- }
131
-
132
82
/// Returns (dependency, crate dependency name)
133
83
pub fn dependencies ( & self , conn : & PgConnection ) -> QueryResult < Vec < ( Dependency , String ) > > {
134
84
Dependency :: belonging_to ( self )
0 commit comments