My initial task is to get a list of nodes that were updated since a given timestamp.
It was clear to me that using the node->changed and views.get method I will be able to make it happen.

Unfortunately, getting into it, I understand that to get this kind of query I need to use filter, and not argument.
Am I wrong ?

So, if filters are required, the existing views.get don't do the work.
The solution, I guess, it to as an additional field to the views.get, with some kind of key-value pairs, and set the filters accordingly.

Any suggestion ?
Is there any other simpler way to do it ?
Regards,
Shushu

Comments

kylebrowning’s picture

Category: feature » support
shushu’s picture

@kylebrowning - does making this a support request instead of feature request means this feature exists, and I just need to understand how to use it ?
If this does not exist - why is it a support request ? Or maybe I don't understand the different categories properly...

kylebrowning’s picture

Well, 2.x is feature frozen, so really this is a support request to see if its possible.

Why cant you use arguments?

I just made a view with view with the updated date as argument, passed in the time and it worked,

$view = new view;
$view->name = 'test';
$view->description = 'test';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Title',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'changed_fulldate' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'id' => 'changed_fulldate',
    'table' => 'node',
    'field' => 'changed_fulldate',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_fixed' => '',
    'default_argument_user' => 0,
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'page' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
shushu’s picture

When you say "worked" I believe you mean it gives results, but the question is what are those results.
With argument, you can get the nodes that were changed in a given date, as you can see in the SQL created from your view:

SELECT node.nid AS nid, node.title AS node_title FROM node node  WHERE DATE_FORMAT((FROM_UNIXTIME(node.changed) + INTERVAL 7200 SECOND), '%Y%m%d') = '20110101'

While I need is the nodes changed since X, as created when using filter:

SELECT node.nid AS nid, node.title AS node_title FROM node node  WHERE node.changed >= 1293832800

So, any suggestion ?

shushu’s picture

Version: 6.x-2.4 » 6.x-2.2
Assigned: Unassigned » shushu
Status: Active » Needs review
StatusFileSize
new2.93 KB

I understand the branch is feature freeze, but since this is what I am working on, here is the patch.
Works great for me.

marcingy’s picture

Version: 6.x-2.2 » 6.x-2.4
Status: Needs review » Needs work

Patches are always against head

shushu’s picture

Version: 6.x-2.4 » 6.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new2.87 KB

Patch against 6.x-2.x

marcingy’s picture

Category: support » feature

On thinking more about this I'm not happy to commit the patch to be honest as it changes the api. Number of comments though that might help to get this in, can we remove the browser related code, the display is available as a parameter it just needs to be explictly passed in.

Can we have more meaning variable names $arr, what is this? Of course I can tell what it is but a proper name would make it fair easier to read the code.

Why is this being called twice

$filter_object = $view->get_item($display_id, 'filter', $key);

The second call certainly is unneeded.

marcingy’s picture

Status: Needs review » Needs work
shushu’s picture

Sorry for the double get_item (will be removed) and for the $arr name (will be fixed).
Regarding to the API change - it is just an addition, can't we live with that ?

marcingy’s picture

Thanks for doing those changes.

I need to speak to others on the services team to decide if we want to put it in, plus it would be ideal if others who use the views service can also test the issue and let us know if it has any impact on existing views. There is the a possibility it could get in if there is no impact in that area.

shushu’s picture

Status: Needs work » Needs review
StatusFileSize
new2.87 KB

Fix code based on @marcingy feedback

marcingy’s picture

Status: Needs review » Needs work

Looks like the same patch as in #7, I assuming you just attached the wrong one?

shushu’s picture

New to git, I didn't commit...
But after commit, creating a patch makes a patch file per commit (so I get two files).
Any idea how to create a "merged" patch ?
Thanks

marcingy’s picture

Status: Needs work » Closed (won't fix)

This isn't going to go into 2.x and 3.x now has its own views project

digitalfrontiersmedia’s picture

shushu,

Despite this not being committed to 2.x branch, I am still very much interested in the same thing, and I'm using the 2.x branch. Any chance you can still post the updated patch or list code or send me a copy?

Thanks!
Stephen

shushu’s picture

no problem.
just remind me if I forget sending it to you in couple of days...