From: Minje Ahn Date: Mon, 23 Mar 2020 03:54:20 +0000 (+0900) Subject: Remove unnecessary fields from the query X-Git-Tag: accepted/tizen/unified/20200325.144443~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c83913ab5a916a3cd85b3436f55062cb20217fb4;p=platform%2Fcore%2Fapi%2Fmedia-content.git Remove unnecessary fields from the query Change-Id: Iaababb7ba3cb636689fc49594c3323742e288074 Signed-off-by: Minje Ahn --- diff --git a/include/media_info_private.h b/include/media_info_private.h index f03e8e5..f0f6ea0 100755 --- a/include/media_info_private.h +++ b/include/media_info_private.h @@ -404,7 +404,8 @@ typedef struct _media_content_cb_data { /*count(distinct x) count only non-null values, but select distinct X returns include null. so sync the result of count and list, don't use count(distinct x)*/ /* Get Media Count of Group */ -#define SELECT_MEDIA_COUNT_FROM_MEDIA "SELECT COUNT(*) FROM ("SELECT_MEDIA_ITEM /*to apply limit condition. "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1" */ +#define SELECT_MEDIA_COUNT_FROM_MEDIA "SELECT COUNT(*) FROM (SELECT media_id FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) " +#define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_MEDIA"AND storage_uuid='%s' " #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) " #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE"AND storage_uuid='%s' " #define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity IN (1, 2) AND album_id='%d' " diff --git a/include_product/media_info_private.h b/include_product/media_info_private.h index 7e728fe..0a5ce35 100755 --- a/include_product/media_info_private.h +++ b/include_product/media_info_private.h @@ -576,7 +576,7 @@ typedef struct _media_content_scan_cb_data_v2 { /*count(distinct x) count only non-null values, but select distinct X returns include null. so sync the result of count and list, don't use count(distinct x)*/ /* Get Media Count of Group */ -#define SELECT_MEDIA_COUNT_FROM_MEDIA "SELECT COUNT(*) FROM ("SELECT_MEDIA_ITEM /*to apply limit condition. "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1" */ +#define SELECT_MEDIA_COUNT_FROM_MEDIA "SELECT COUNT(*) FROM (SELECT media_id FROM '%s' WHERE validity=1 " /*to apply limit condition. "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1" */ #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM '%s' WHERE validity=1 " #define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND album_id='%d'" #define SELECT_MEDIA_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP /*to apply limit condition. */ diff --git a/src/media_content.c b/src/media_content.c index 4aa9fb5..14c763c 100644 --- a/src/media_content.c +++ b/src/media_content.c @@ -567,13 +567,11 @@ int media_content_set_db_updated_cb(media_content_db_update_cb callback, void *u } #endif -void __media_content_clear_user_data(void *user_data) +static void __media_content_clear_user_data(void *user_data) { media_noti_cb_s *noti_info = user_data; SAFE_FREE(noti_info); - - return; } int media_content_remove_db_updated_cb(media_content_noti_h noti_handle) diff --git a/src/media_db.c b/src/media_db.c index 9ab32b2..f9d144d 100755 --- a/src/media_db.c +++ b/src/media_db.c @@ -1090,9 +1090,16 @@ int _media_db_get_group_item_count(const char *group_name, filter_h filter, grou #endif } else { #ifdef _USE_TVPD_MODE - snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA, DB_VIEW_MEDIA); + if (STRING_VALID(_filter->storage_id)) + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA, _filter->storage_id); + else + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA, DB_VIEW_MEDIA); #else - snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA); + if (STRING_VALID(_filter->storage_id)) + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA_BY_STORAGE_ID, _filter->storage_id); + else + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA); + #endif need_bracket = true; }