Changeset 29244


Ignore:
Timestamp:
Aug 22, 2014, 10:56:51 AM (10 years ago)
Author:
plg
Message:

feature 2810: for duplicates filter, add "date & time" (checked by default) and "width & height" as options.

Change algorithm for a single SQL query with GROUP_CONCAT instead of 2 queries.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r29238 r29244  
    8080  {
    8181    $_SESSION['bulk_manager_filter']['prefilter'] = $_POST['filter_prefilter'];
     82
     83    if ('duplicates' == $_POST['filter_prefilter'])
     84    {
     85      if (isset($_POST['filter_duplicates_date']))
     86      {
     87        $_SESSION['bulk_manager_filter']['duplicates_date'] = true;
     88      }
     89     
     90      if (isset($_POST['filter_duplicates_dimensions']))
     91      {
     92        $_SESSION['bulk_manager_filter']['duplicates_dimensions'] = true;
     93      }
     94    }
    8295  }
    8396
     
    301314
    302315  case 'duplicates':
    303     // we could use the group_concat MySQL function to retrieve the list of
    304     // image_ids but it would not be compatible with PostgreSQL, so let's
    305     // perform 2 queries instead. We hope there are not too many duplicates.
    306     $query = '
    307 SELECT file
    308   FROM '.IMAGES_TABLE.'
    309   GROUP BY file, date_creation
     316    $duplicates_on_fields = array('file');
     317
     318    if (isset($_SESSION['bulk_manager_filter']['duplicates_date']))
     319    {
     320      $duplicates_on_fields[] = 'date_creation';
     321    }
     322   
     323    if (isset($_SESSION['bulk_manager_filter']['duplicates_dimensions']))
     324    {
     325      $duplicates_on_fields[] = 'width';
     326      $duplicates_on_fields[] = 'height';
     327    }
     328   
     329    $query = '
     330SELECT
     331    GROUP_CONCAT(id) AS ids
     332  FROM '.IMAGES_TABLE.'
     333  GROUP BY '.implode(',', $duplicates_on_fields).'
    310334  HAVING COUNT(*) > 1
    311335;';
    312     $duplicate_files = query2array($query, null, 'file');
    313 
    314     $query = '
    315 SELECT id
    316   FROM '.IMAGES_TABLE.'
    317   WHERE file IN (\''.implode("','", array_map('pwg_db_real_escape_string', $duplicate_files)).'\')
    318 ;';
    319     $filter_sets[] = query2array($query, null, 'id');
     336    $array_of_ids_string = query2array($query, null, 'ids');
     337
     338    $ids = array();
     339   
     340    foreach ($array_of_ids_string as $ids_string)
     341    {
     342      $ids = array_merge($ids, explode(',', $ids_string));
     343    }
     344   
     345    $filter_sets[] = $ids;
    320346
    321347    break;
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r29238 r29244  
    393393  jQuery("select[name=filter_prefilter]").change(function() {
    394394    jQuery("#empty_caddie").toggle(jQuery(this).val() == "caddie");
     395    jQuery("#duplicates_options").toggle(jQuery(this).val() == "duplicates");
    395396  });
    396397});
     
    419420        </select>
    420421        <a id="empty_caddie" href="admin.php?page=batch_manager&amp;action=empty_caddie" style="{if !isset($filter.prefilter) or $filter.prefilter ne 'caddie'}display:none{/if}">{'Empty caddie'|translate}</a>
     422
     423        <span id="duplicates_options" style="{if !isset($filter.prefilter) or $filter.prefilter ne 'duplicates'}display:none{/if}">
     424          {'based on'|translate}
     425          <input type="checkbox" checked="checked" disabled="disabled"> {'file name'|translate}
     426          <label><input type="checkbox" name="filter_duplicates_date" {if isset($filter.duplicates_date) or (isset($filter.prefilter) and $filter.prefilter ne 'duplicates')}checked="checked"{/if}> {'date & time'|translate}</label>
     427          <label><input type="checkbox" name="filter_duplicates_dimensions" {if isset($filter.duplicates_dimensions)}checked="checked"{/if}> {'width & height'|translate}</label>
     428        </span>
    421429      </li>
    422430
  • trunk/admin/themes/default/theme.css

    r29238 r29244  
    982982#batchManagerGlobal .ui-slider-horizontal {width:650px;margin:5px 0 10px 0;}
    983983
     984#batchManagerGlobal #duplicates_options label {margin-left:10px;}
     985
    984986#order_filters a.addFilter {font-weight:normal;margin-left:20px;}
    985987#order_filters a.removeFilter {font-weight:normal;}
  • trunk/language/en_UK/admin.lang.php

    r29238 r29244  
    977977$lang['Empty caddie'] = 'Empty caddie';
    978978$lang['between %s and %s MB'] = 'between %s and %s MB';
     979$lang['based on'] = 'based on';
     980$lang['file name'] = 'file name';
     981$lang['date & time'] = 'date & time';
     982$lang['width & height'] = 'width & height';
    979983?>
  • trunk/language/fr_FR/admin.lang.php

    r29238 r29244  
    979979$lang['The settings for the guest are from the %s user'] = 'Les préféreces des invités sont celles de l\'utilisateur %s';
    980980$lang['between %s and %s MB'] = 'entre %s et %s Mo';
     981$lang['based on'] = 'basé sur';
     982$lang['file name'] = 'nom de fichier';
     983$lang['date & time'] = 'date et heure';
     984$lang['width & height'] = 'largeur et hauteur';
Note: See TracChangeset for help on using the changeset viewer.