Opened 4 years ago

Closed 3 years ago

#1373 closed Bug (fixed)

Visitor Generator should update website ts_created field with earliest date

Reported by: JulienM Owned by:
Priority: low Milestone: Piwik 1.2
Component: Core Keywords:
Cc: Sensitive: no

Description

Scenario:

1) Create a site

2) Generate visits for 2 days (ie. set $daysToCompute to 2 in /misc/generateVisits.php#15)

3) Access dashboard

4) Setting the calendar to day n-1 is not permitted even though there is data generated for that day

Proposal: In /trunk/core/Controller.php#322 replace $this->site->getCreationDate()->getDatetime(); by a query to the database to get the oldest date from the database.

If an "import piwik data" functionality would be developed later on, data older than the creation date of a site could be created. The same issue would occur.

Change History (10)

comment:1 Changed 4 years ago by vipsoft (robocoder)

  • Milestone set to 2 - Piwik 0.8 - A Web Analytics platform

Since the Site record is already loaded (i.e., avoid adding a new, potentially slow, query) and rather than deprecating this column, an alternative would be to add a method to change ts_created to reflect the earliest date for generated/imported data.

comment:2 Changed 4 years ago by JulienM (JulienMoumne)

Wouldn't it be useful to leave untouched the ts_created field if one day the initial value is needed ?

It may be wise to keep the two concepts well separated. One date is the site administrative creation date within a particular instance of piwik (ts_created). The other date is the earliest known visit recorded for the website.

comment:3 Changed 4 years ago by vipsoft (robocoder)

Not really, since getCreationDate() loses its meaning/intent/value if the database is populated with older data. In these cases, I suspect we have to add code to reprocess the archives.

comment:4 Changed 4 years ago by matt (mattab)

agreed with vipsoft, it would be easier to update the ts_created time directly at the end of the visit generator process (less overhead, and the ts_created is not really useful if the user created fake visits anyway... as this is probably a fake/testing/temporary piwik website)

comment:5 Changed 4 years ago by matt (mattab)

  • Milestone changed from 2 - Piwik 0.8 - A Web Analytics platform to 4 - Piwik 1.0 - Stable release
  • Summary changed from minDateView used by calendar based on website creation date, should be based on actual visit data to Visitor Generator should update website ts_created field with earliest date

comment:6 Changed 4 years ago by halfdan

What implementation is preferred now?

Should the Visitor Generator:

  • send a plain SQL-Query to the database and change ts_created?
  • call a new API method (or: updateSite(.., ts_created = ) ) to update ts_created?

comment:7 Changed 4 years ago by matt (mattab)

ts_created cant be updated via API (not logical) so you can do it manually, or refactor in Core the following code from Integration->createWebsite

    	// Manually set the website creation date to a day earlier than the earliest day we record stats for
		Zend_Registry::get('db')->update(Piwik_Common::prefixTable("site"), 
                							array('ts_created' => Piwik_Date::factory($dateTime)->subDay(1)->getDatetime()),
                							"idsite = $idSite"
                								);
								

comment:8 Changed 4 years ago by matt (mattab)

  • Milestone changed from 4 - Piwik 1.0 - Stable release to Features requests - after Piwik 1.0

comment:9 Changed 3 years ago by matt (mattab)

  • Milestone changed from Feature requests to 1.2 Piwik 1.2

confusing and easy to fix, let's do it

comment:10 Changed 3 years ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from new to closed

(In [3660]) Fixes #1373

Note: See TracTickets for help on using tickets.