@@ -4,6 +4,7 @@ use crate::model::Crud;
44use crate :: schema:: { file, file_upload} ;
55use diesel:: prelude:: * ;
66use diesel:: OptionalExtension ;
7+ use diesel:: { QueryDsl , RunQueryDsl } ;
78use thoth_errors:: { ThothError , ThothResult } ;
89use uuid:: Uuid ;
910
@@ -50,8 +51,6 @@ impl Crud for File {
5051 }
5152
5253 fn from_id ( db : & crate :: db:: PgPool , entity_id : & Uuid ) -> ThothResult < Self > {
53- use diesel:: QueryDsl ;
54- use diesel:: RunQueryDsl ;
5554 let mut connection = db. get ( ) ?;
5655 file:: table
5756 . find ( entity_id)
@@ -77,8 +76,6 @@ impl Crud for File {
7776 }
7877
7978 fn delete ( self , db : & crate :: db:: PgPool ) -> ThothResult < Self > {
80- use diesel:: QueryDsl ;
81- use diesel:: RunQueryDsl ;
8279 let mut connection = db. get ( ) ?;
8380 diesel:: delete ( file:: table. find ( self . file_id ) )
8481 . execute ( & mut connection)
@@ -143,8 +140,6 @@ impl Crud for FileUpload {
143140 }
144141
145142 fn from_id ( db : & crate :: db:: PgPool , entity_id : & Uuid ) -> ThothResult < Self > {
146- use diesel:: QueryDsl ;
147- use diesel:: RunQueryDsl ;
148143 let mut connection = db. get ( ) ?;
149144 file_upload:: table
150145 . find ( entity_id)
@@ -170,8 +165,6 @@ impl Crud for FileUpload {
170165 }
171166
172167 fn delete ( self , db : & crate :: db:: PgPool ) -> ThothResult < Self > {
173- use diesel:: QueryDsl ;
174- use diesel:: RunQueryDsl ;
175168 let mut connection = db. get ( ) ?;
176169 diesel:: delete ( file_upload:: table. find ( self . file_upload_id ) )
177170 . execute ( & mut connection)
@@ -196,8 +189,6 @@ impl Crud for FileUpload {
196189impl File {
197190 pub fn from_object_key ( db : & crate :: db:: PgPool , object_key : & str ) -> ThothResult < Self > {
198191 use crate :: schema:: file:: dsl;
199- use diesel:: QueryDsl ;
200- use diesel:: RunQueryDsl ;
201192
202193 let mut connection = db. get ( ) ?;
203194 dsl:: file
@@ -208,8 +199,6 @@ impl File {
208199
209200 pub fn from_work_id ( db : & crate :: db:: PgPool , work_id : & Uuid ) -> ThothResult < Option < Self > > {
210201 use crate :: schema:: file:: dsl;
211- use diesel:: QueryDsl ;
212- use diesel:: RunQueryDsl ;
213202
214203 let mut connection = db. get ( ) ?;
215204 dsl:: file
@@ -225,8 +214,6 @@ impl File {
225214 publication_id : & Uuid ,
226215 ) -> ThothResult < Option < Self > > {
227216 use crate :: schema:: file:: dsl;
228- use diesel:: QueryDsl ;
229- use diesel:: RunQueryDsl ;
230217
231218 let mut connection = db. get ( ) ?;
232219 dsl:: file
0 commit comments