mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
Add ability to suppress logging of known unsuccessful API calls (#5526)
This commit is contained in:
parent
ba11f0d06e
commit
c6cb97e199
4 changed files with 46 additions and 3 deletions
|
|
@ -130,6 +130,17 @@ class MediaClient @Inject constructor(
|
|||
.map { it.first() }
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches Media object from the imageInfo API but suppress (known) errors
|
||||
*
|
||||
* @param titles the tiles to be searched for. Can be filename or template name
|
||||
* @return
|
||||
*/
|
||||
fun getMediaSuppressingErrors(titles: String?): Single<Media> {
|
||||
return responseMapper(mediaInterface.getMediaSuppressingErrors(titles))
|
||||
.map { it.first() }
|
||||
}
|
||||
|
||||
/**
|
||||
* The method returns the picture of the day
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package fr.free.nrw.commons.media;
|
||||
|
||||
import static fr.free.nrw.commons.OkHttpConnectionFactory.UnsuccessfulResponseInterceptor.SUPPRESS_ERROR_LOG_HEADER;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import java.util.Map;
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwQueryResponse;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.Query;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
|
|
@ -103,6 +106,17 @@ public interface MediaInterface {
|
|||
MEDIA_PARAMS_WITH_CATEGORY_DETAILS)
|
||||
Single<MwQueryResponse> getMedia(@Query("titles") String title);
|
||||
|
||||
/**
|
||||
* Fetches Media object from the imageInfo API but suppress (known) errors
|
||||
*
|
||||
* @param title the tiles to be searched for. Can be filename or template name
|
||||
* @return
|
||||
*/
|
||||
@GET("w/api.php?action=query&format=json&formatversion=2" +
|
||||
MEDIA_PARAMS_WITH_CATEGORY_DETAILS)
|
||||
@Headers(SUPPRESS_ERROR_LOG_HEADER)
|
||||
Single<MwQueryResponse> getMediaSuppressingErrors(@Query("titles") String title);
|
||||
|
||||
/**
|
||||
* Fetches Media object from the imageInfo API
|
||||
*
|
||||
|
|
@ -111,6 +125,7 @@ public interface MediaInterface {
|
|||
*/
|
||||
@GET("w/api.php?action=query&format=json&formatversion=2" +
|
||||
MEDIA_PARAMS)
|
||||
@Headers(SUPPRESS_ERROR_LOG_HEADER)
|
||||
Single<MwQueryResponse> getMediaById(@Query("pageids") String pageIds);
|
||||
|
||||
/**
|
||||
|
|
@ -125,6 +140,7 @@ public interface MediaInterface {
|
|||
Single<MwQueryResponse> getMediaWithGenerator(@Query("titles") String title);
|
||||
|
||||
@GET("w/api.php?format=json&action=parse&prop=text")
|
||||
@Headers(SUPPRESS_ERROR_LOG_HEADER)
|
||||
Single<MwParseResponse> getPageHtml(@Query("page") String title);
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue