i have a content type, say named material, with fields and all, and users can create, modify and delete all nodes of content type material.
The task i need to do, is have a report on the activity of each user, in a per month, or a per year basis. Example user 1, has created the following nodes, in January, updated these nodes and how many times each node was updated by the particular user.
Is there a module, or a view that could help me do something like this?
Or should i go to MySQL and run a query there?
And how then this query should look like?
(I am still on version 7 of drupal)
for example the following will return will select all nodes created within the past hour (3600 seconds).
$result = db_query("SELECT nid, title FROM {node} WHERE created > :created", array(
':created' => REQUEST_TIME - 3600,
));
But what i need is also all updates done by a certain user, for a certain period of time given...
Any example would be highly appreciated.
Related
wocoommerce after each change status on an order sends comments that types are "order_note" in database.
how can i remove all or disable some of it.
they are 36000 rows in my database now.
some of the order status note comments are not important for us.
picture
36000 rows actually is not that big of a deal. WooCommerce has many performance and database structure related imperfections you should keep in mind, this is probably not one of them.
Anyway...
WooCommerce stores it's order notes inside wp_comments table, with the comment type set as order_note.
You can safely delete these rows as you wish. For example if you want to delete order notes from year 2021 and earlier (and keep only those from 2022), you can run this query:
DELETE FROM `wp_comments` WHERE `comment_type` = 'order_note' AND `comment_date` <= '2021-12-31';
If you want to delete order notes for specific order IDs (e.g. for order 12345 and older), you can do it the similar way:
DELETE FROM `wp_comments` WHERE `comment_type` = 'order_note' AND `comment_post_ID` <= 12345;
You can implement this SQL query as a PHP script using $wpdb, e.g. to automatically delete order notes, that had been created last year or earlier:
global $wpdb;
// Delete all order notes created last year and earlier
$delete_before = date( 'Y-m-d', strtotime( 'last year December 31st' ) );
$wpdb->query($wpdb->prepare("DELETE FROM `wp_comments` WHERE `comment_type` = 'order_note' AND `comment_date` <= %s;", $delete_before));
You can implement such script as a function and trigger it automatically, either with wp_schedule_event() or as a standard CRON job.
I Use DataCollection on SSMA\Object Explorer\Management\DataCollection in 2 day ago.
But each time I get report from Data Collection, no data available to display. The following image is a sample Server Activity History report of data collection reports.
this query will confirm if a snapshot was actually taken on that date: (change the name of your Data Management Warehouse)
SELECT [snapshot_time_id]
,[snapshot_time]
FROM [DATA_MANAGEMENT_WAREHOUSE].[core].[snapshot_timetable_internal]
WHERE CAST(snapshot_time AS DATE) = CAST('2014-06-19' AS DATE)
if there is no result set, run without the filter to confirm when the snapshots first started and what the interval is.
SELECT [snapshot_time_id]
,[snapshot_time]
FROM [DATA_MANAGEMENT_WAREHOUSE].[core].[snapshot_timetable_internal]
Then, if you have no results, check to see if the Agent service is on. I believe it could be related to one of these things.
EDIT: added another query to check for wait stats.
SELECT [wait_type]
,[waiting_tasks_count]
,[wait_time_ms]
,[signal_wait_time_ms]
,[collection_time]
,[snapshot_id]
FROM [DATA_MANAGEMENT_WAREHOUSE].[snapshots].[os_wait_stats]
I have many products (product_id). Users (user_id) view the products.
I want to query which users viewed whatever product in the last 24 hours. (In other words, I want to keep a list of user_ids attached to that product_id...and when 24 hours is up for a user, that user pops off that list and the record disappears)
How do I store this in Redis? Can someone give me a high-level schema because I'm new in Redis.
For something similar I use a sorted set with values being user ids and score being the current time. When updating the set, remove older items with ZREMRANGEBYSCORE as well as updating the time score for the current user.
Update with code:
Whenever a new item is added:
ZREMRANGEBYSCORE recentitems 0 [DateTime.Now.AddMinutes(-10).Ticks]
ZADD recentitems [DateTime.Now.Ticks] [item.id]
To get the ids of items added in the last 10 minutes:
ZREVRANGEBYSCORE recentitems [DateTime.Now.Ticks] [DateTime.Now.AddMinutes(-10).Ticks]
Note that you could also use
ZREVRANGE recentitems 0 -1
if you don't mind that the set could include older items if nothing has been added recently.
That gets you a list of item ids. You then use GET/MGET/HGET/HMGET as appropriate to retrieve the actual items for display.
If you want redis keys to drop off automatically then you'll probably want to use a redis key for every user_id-to-product_id map. So, you would write by doing something like redis.set "user-to-products:user_id:product_id", timestamp followed by redis.expire "user-to-products:user_id:product_id" 86400 (24hrs, in seconds).
To retrieve the current list you should be able to do redis.keys "user-to-products:user_id:*"
I'm running in a problem with cakephp pagination. Currently, my pagination is rather standard. After x results, it creates a second page. And so on.
What i would like to do is to order them by month. As it is a news archive, I would like to be able to select the month instead of the page.
So instead:
Page 1
Page 2
Page 3
I would like to have:
January 2010
February 2010
March 2010
How is this possible? I can't seem to find it. My current code:
var $paginate = array('limit' => 50, 'page' => 1, 'order'=>array('Newsitem.created'=>'DESC'));
thanks in advance!!
Pagination is a function of LIMIT row counts and offsets of number of records, not by data conditions. Therefore, you will not be able to use the pagination function in cake to accomplish this. You will need to create a custom solution to accomplish this. If you continue to solve this with the build in cake pagination, you will continue to hit a brick wall.
Now, that being said, one solution is to paginate by month. So you could have different links down the left showing the months (i.e. January 2010, February 2010, etc.), when they select one of those options, it will paginate all of the results for the given date.
This might be an alternative you'd consider (it doesn't match your requirement directly).
CakePHP Filter Plugin
What it would allow you is filtering paginated data by any column in the recordset.
Under any header (<th>) you'll be able to add an input where you can enter filter criteria (e.g. for Newsitem.created you could enter: 2010-08 to display/paginate only Newsitems for Aug. 2010). You then click the filter button and your page reloads showing only the records that match the filtered criteria. Works with Ajax pagination also.
I tested this today with this screen:
Magento database name convention is not trivial. How to get these fields below for last 7 days?
Last Name
First Name
Address
City
State
Zip
Phone
Email
Amount
Order #
Item #
I could not tell if you were looking for some PHP/Magento code or if you are looking to access the database directly. It might be "better" to create yourself a custom module that fetches this info using the Magento/Zend framework, but since I don't know the code off the top of my head I'll redirect you to the following link which has a very nice SQL query that will pull that info for you (and more).
http://www.magentocommerce.com/wiki/groups/207/fedex_-_shipping_view
You probably just need to add something like this to the end to filter the last 7 days
where so.created_at > NOW() - INTERVAL 7 DAY