@@ -60,12 +60,12 @@ impl DatabaseDownloadsMetricRepository {
6060 /// # Errors
6161 ///
6262 /// Returns an [`Error`] if the database operation fails.
63- pub ( crate ) fn increase_number_of_downloads ( & self , info_hash : & InfoHash ) -> Result < ( ) , Error > {
64- let torrent = self . load ( info_hash) ?;
63+ pub ( crate ) fn increase_downloads_for_torrent ( & self , info_hash : & InfoHash ) -> Result < ( ) , Error > {
64+ let torrent = self . load_torrent_downloads ( info_hash) ?;
6565
6666 match torrent {
67- Some ( _number_of_downloads) => self . database . increase_number_of_downloads ( info_hash) ,
68- None => self . save ( info_hash, 1 ) ,
67+ Some ( _number_of_downloads) => self . database . increase_downloads_for_torrent ( info_hash) ,
68+ None => self . save_torrent_downloads ( info_hash, 1 ) ,
6969 }
7070 }
7171
@@ -77,8 +77,8 @@ impl DatabaseDownloadsMetricRepository {
7777 /// # Errors
7878 ///
7979 /// Returns an [`Error`] if the underlying database query fails.
80- pub ( crate ) fn load_all ( & self ) -> Result < PersistentTorrents , Error > {
81- self . database . load_persistent_torrents ( )
80+ pub ( crate ) fn load_all_torrents_downloads ( & self ) -> Result < PersistentTorrents , Error > {
81+ self . database . load_all_torrents_downloads ( )
8282 }
8383
8484 /// Loads one persistent torrent metrics from the database.
@@ -89,8 +89,8 @@ impl DatabaseDownloadsMetricRepository {
8989 /// # Errors
9090 ///
9191 /// Returns an [`Error`] if the underlying database query fails.
92- pub ( crate ) fn load ( & self , info_hash : & InfoHash ) -> Result < Option < PersistentTorrent > , Error > {
93- self . database . load_persistent_torrent ( info_hash)
92+ pub ( crate ) fn load_torrent_downloads ( & self , info_hash : & InfoHash ) -> Result < Option < PersistentTorrent > , Error > {
93+ self . database . load_torrent_downloads ( info_hash)
9494 }
9595
9696 /// Saves the persistent torrent metric into the database.
@@ -106,8 +106,8 @@ impl DatabaseDownloadsMetricRepository {
106106 /// # Errors
107107 ///
108108 /// Returns an [`Error`] if the database operation fails.
109- pub ( crate ) fn save ( & self , info_hash : & InfoHash , downloaded : u32 ) -> Result < ( ) , Error > {
110- self . database . save_persistent_torrent ( info_hash, downloaded)
109+ pub ( crate ) fn save_torrent_downloads ( & self , info_hash : & InfoHash , downloaded : u32 ) -> Result < ( ) , Error > {
110+ self . database . save_torrent_downloads ( info_hash, downloaded)
111111 }
112112
113113 // Aggregate Metrics
@@ -119,12 +119,12 @@ impl DatabaseDownloadsMetricRepository {
119119 /// # Errors
120120 ///
121121 /// Returns an [`Error`] if the database operation fails.
122- pub ( crate ) fn increase_global_number_of_downloads ( & self ) -> Result < ( ) , Error > {
123- let torrent = self . database . load_global_number_of_downloads ( ) ?;
122+ pub ( crate ) fn increase_global_downloads ( & self ) -> Result < ( ) , Error > {
123+ let torrent = self . database . load_global_downloads ( ) ?;
124124
125125 match torrent {
126- Some ( _number_of_downloads) => self . database . increase_global_number_of_downloads ( ) ,
127- None => self . database . save_global_number_of_downloads ( 1 ) ,
126+ Some ( _number_of_downloads) => self . database . increase_global_downloads ( ) ,
127+ None => self . database . save_global_downloads ( 1 ) ,
128128 }
129129 }
130130
@@ -133,8 +133,8 @@ impl DatabaseDownloadsMetricRepository {
133133 /// # Errors
134134 ///
135135 /// Returns an [`Error`] if the underlying database query fails.
136- pub ( crate ) fn load_global_number_of_downloads ( & self ) -> Result < Option < PersistentTorrent > , Error > {
137- self . database . load_global_number_of_downloads ( )
136+ pub ( crate ) fn load_global_downloads ( & self ) -> Result < Option < PersistentTorrent > , Error > {
137+ self . database . load_global_downloads ( )
138138 }
139139}
140140
@@ -159,9 +159,9 @@ mod tests {
159159
160160 let infohash = sample_info_hash ( ) ;
161161
162- repository. save ( & infohash, 1 ) . unwrap ( ) ;
162+ repository. save_torrent_downloads ( & infohash, 1 ) . unwrap ( ) ;
163163
164- let torrents = repository. load_all ( ) . unwrap ( ) ;
164+ let torrents = repository. load_all_torrents_downloads ( ) . unwrap ( ) ;
165165
166166 assert_eq ! ( torrents. get( & infohash) , Some ( 1 ) . as_ref( ) ) ;
167167 }
@@ -172,9 +172,9 @@ mod tests {
172172
173173 let infohash = sample_info_hash ( ) ;
174174
175- repository. increase_number_of_downloads ( & infohash) . unwrap ( ) ;
175+ repository. increase_downloads_for_torrent ( & infohash) . unwrap ( ) ;
176176
177- let torrents = repository. load_all ( ) . unwrap ( ) ;
177+ let torrents = repository. load_all_torrents_downloads ( ) . unwrap ( ) ;
178178
179179 assert_eq ! ( torrents. get( & infohash) , Some ( 1 ) . as_ref( ) ) ;
180180 }
@@ -186,10 +186,10 @@ mod tests {
186186 let infohash_one = sample_info_hash_one ( ) ;
187187 let infohash_two = sample_info_hash_two ( ) ;
188188
189- repository. save ( & infohash_one, 1 ) . unwrap ( ) ;
190- repository. save ( & infohash_two, 2 ) . unwrap ( ) ;
189+ repository. save_torrent_downloads ( & infohash_one, 1 ) . unwrap ( ) ;
190+ repository. save_torrent_downloads ( & infohash_two, 2 ) . unwrap ( ) ;
191191
192- let torrents = repository. load_all ( ) . unwrap ( ) ;
192+ let torrents = repository. load_all_torrents_downloads ( ) . unwrap ( ) ;
193193
194194 let mut expected_torrents = PersistentTorrents :: new ( ) ;
195195 expected_torrents. insert ( infohash_one, 1 ) ;
0 commit comments