Forums / Developer / removing duplicate entries from 2 independent fetches

removing duplicate entries from 2 independent fetches

Author Message

steve walker

Wednesday 08 September 2004 8:28:12 am

Hi there,

I started to ask about this at the end of http://ez.no/community/forum/setup_design/advanced_search_development_homemade_fuzzy_logic but its really a seperate subject so wanted to start a fresh thread.

I have 2 independent fetches with the 2nd fetch likely to contain some identical data to the first fetch.

I want to perform some filtering on the second fetch so that it doesnt display any of the data that was already displayed via the first fetch.

Does anyone know of a way of doing this.

Many thanks, Steve.

http://www.oneworldmarket.co.uk

Ole Morten Halvorsen

Thursday 09 September 2004 2:09:10 am

Steve,

If the <b>unique</b> operator (http://ez.no/ez_publish/documentation/reference/template_operators/arrays/unique) cant help you I would recommend writing an operator for this purpose.

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

steve walker

Thursday 09 September 2004 2:24:53 am

Ole,

OK. In this case the potential issue is I have two independent fetches.

Is it possible to make an array out of the 2 fetches, so I have something on the lines of:

let fetch1 = fetch_some_data
let fetch2 = fectch_additional_data

let overall_results = array(fetch1,fetch2)|unique

RegardsSteve.

http://www.oneworldmarket.co.uk

Ole Morten Halvorsen

Thursday 09 September 2004 5:36:29 am

Steve,

Yes, you can use merge the two arrays with <b>merge</b>. Look here: http://ez.no/ez_publish/documentation/reference/template_operators/arrays/merge

I dont think the unique operator works on multidimensional arrays, so you might have to write your own operator to do this.

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

steve walker

Wednesday 15 September 2004 2:18:37 am

Ole,

Thanks for the information.

Regards, Steve.

http://www.oneworldmarket.co.uk

willy jansen

Wednesday 15 September 2004 7:33:38 am

Hi,

A slight different question. I have a fetch that returns duplicate entries (because there are articles that appear in more than 1 location).

Can I use "unique" to filter the duplicate entries out?

If yes: how?

Find below the code I'm using...
(It fetches the latest 6 additions from 100 nodes starting from node 2)

{let page_limit=8 
children=fetch(content, list, hash(limit, 6, 
parent_node_id, 2, 
depth, 100, sort_by,array(published,false()), 
class_filter_type, include, class_filter_array, array(article)))}

  <table class="2cols">
      <tr>
      {section name=Child loop=$children sequence=array(col1,col2)} 
        <td valign="top" class="{$Child:sequence}">
         {node_view_gui view=line content_node=$Child:item}
        </td>
        {delimiter modulo=2}
         </tr>
         <tr>
        {/delimiter}

      {/section}
    </tr>
  </table>

I'd highly appreciate a hint in the right direction.

steve walker

Wednesday 15 September 2004 8:02:24 am

Willy,

Have a look at:

http://www.ez.no/community/bug_reports/duplicates_when_fetching_trees_and_lists_with_objects_assigned_to_multiple_locations

You want to use the 'main_node_only, true()' within the fetch to only grab main node.

Regards, Steve.

http://www.oneworldmarket.co.uk

willy jansen

Wednesday 15 September 2004 9:36:21 am

Splendid.

This fetch does the trick now for me:

{let page_limit=8 
children=fetch(content, list, 
hash(limit, 6, parent_node_id, 2, 
depth, 100, main_node_only, true(), 
sort_by,array(published,false()), 
class_filter_type, include, class_filter_array, array(article)))}

John Kazakis

Tuesday 25 March 2008 9:56:34 am

Hello,

I just tried this and it doesn't seem to work :S

Here's my code:

{def $featured_folder = fetch( 'content', 'node', hash( 'node_path', concat($node.path_identification_string, '/featured') ) )
    
     $event_list = fetch( 'content', 'list', 
                          hash( 'parent_node_id',        $featured_folder.node_id,
                                'sort_by',               $featured_folder.sort_array,
                                'limit',                 4,
                                'limitation',            array(),
								main_node_only, true()
                              ) )
}

{*---------------------
    List the Events
---------------------*}
{foreach $event_list as $content sequence array( '0', '1' ) as $style}
    {if eq($style, 0) }
        {append-block variable=$left_components}           
            {node_view_gui view='box' box_type="listbox" content_node=$content display_register='1'}
        {/append-block}
    {else}
        {append-block variable=$right_components}            
            {node_view_gui view='box' box_type="listbox" content_node=$content display_register='1'}
        {/append-block}
    {/if}
{/foreach}

What am I missing?

Thanks.

eZ debug

Timing: Jan 31 2025 01:30:20
Script start
Timing: Jan 31 2025 01:30:20
Module start 'content'
Timing: Jan 31 2025 01:30:20
Module end 'content'
Timing: Jan 31 2025 01:30:20
Script end

Main resources:

Total runtime0.1759 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0087 588.0781370.2734
Module start 'content' 0.00870.0120 958.35161,013.5938
Module end 'content' 0.02070.1552 1,971.94533,902.0391
Script end 0.1759  5,873.9844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00422.4075200.0002
Check MTime0.00130.7276200.0001
Mysql Total
Database connection0.00170.970910.0017
Mysqli_queries0.086349.03411410.0006
Looping result0.00110.63961390.0000
Template Total0.154888.010.1548
Template load0.00080.479210.0008
Template processing0.153987.510710.1539
Override
Cache load0.00060.332010.0006
Sytem overhead
Fetch class attribute can translate value0.00181.019710.0018
XML
Image XML parsing0.00020.112610.0002
General
dbfile0.00563.1623200.0003
String conversion0.00000.003930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs