Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visitor Generator should update website ts_created field with earliest date #1373

Closed
julienmoumne opened this issue May 22, 2010 · 8 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@julienmoumne
Copy link
Member

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.

@robocoder
Copy link
Contributor

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.

@julienmoumne
Copy link
Member Author

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.

@robocoder
Copy link
Contributor

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.

@mattab
Copy link
Member

mattab commented May 24, 2010

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)

@halfdan
Copy link
Member

halfdan commented Jul 15, 2010

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?

@mattab
Copy link
Member

mattab commented Jul 15, 2010

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"
                                                );


@mattab
Copy link
Member

mattab commented Jan 7, 2011

confusing and easy to fix, let's do it

@mattab
Copy link
Member

mattab commented Jan 7, 2011

(In [3660]) Fixes #1373

@julienmoumne julienmoumne added this to the Piwik 1.2 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

4 participants