Extension:WSStats/pl

Category:GPL licensed extensions/pl
Podręcznik rozszerzeń MediaWiki
WSStats
Status wydania: stabilneCategory:Stable extensions/pl
Realizacja Rozszerzenie parsera Category:Parser extensions/pl
Opis Allows to collect page statistics
Autor(zy) Charlot Cobben (Sen-Saidyskusja)
Ostatnia wersja 2.0.3 (2025-03-05)
Polityka zgodności Dla każdego wydania MediaWiki, które jest wydaniem wsparcia długoterminowego, istnieje odpowiednia gałąź w rozszerzeniu.
MediaWiki 1.39+;1.43Category:Extensions with manual MediaWiki version
Zmiany w bazie danych Tak
Composer wikibase-solutions/w-s-statsCategory:Extensions supporting Composer/pl
Licencja Licencja GNU General Public License 2.0 lub późniejsza
Pobieranie Category:Extensions in GitHub version control/pl
README
  • $wgWSSStats
  • <wsstats>
Category:All extensions/pl

The WSStats extension counts pageviews by user using the before page display hook. There is no client JavaScript run or any trackers installed.

Make sure you update to either version 1.0.8 (MW 1.35.x) or 2.0.0 (MW 1.39.x) due to a security risk

Instalacja

  • Pobierz i umieść plik(i) w katalogu o nazwie WSStats w folderze extensions/.
  • Dodaj poniższy kod na dole twojego pliku LocalSettings.php :
    wfLoadExtension( 'WSStats' );
    
  • Uruchom skrypt aktualizujący, który automatycznie stworzy potrzebne tabele dla tego rozszerzenia.
  • Configure as required
  • Yes Zrobione – Przejdź do Special:Version na twojej wiki, aby sprawdzić czy rozszerzenie zostało pomyślnie zainstalowane.

Aktualizowanie

Make sure you always create a backup of your database first!

If you are upgrading from a version before 2.0, then you must visit the special page "Special:WSStats". If the database tables need updating, it will show you there and you can update the tables. You will have to update the tables for statistics to be accurate. This is because we now allow to get statistics based on page titles, while the previous version of WSStats did not store titles.

Konfiguracja

By default anonymous users and sysops are skipped from stats recording. To change this add the following to your "LocalSettings.php" file:

Start with:

$wgWSStats=[];

Allow statistics for anonymous users:

// Record anonymous users
$wgWSStats['skip_anonymous'] = false;

By default special pages are counted as well. To omit special pages set the following:

// Special Pages statistics
$wgWSStats['countSpecialPages'] = false; // defaults to true

Skip users in the following groups..

// Skip if user is in following groups
$wgWSStats['skip_user_groups'][]= 'sysop';
$wgWSStats['skip_user_groups'][]= 'admin';

Skip page with certain text in their referer URL. Default action=edit and veaction=edit are ignored. This configuration option is case sensitive:

$wgWSStats['ignore_in_url'][] = 'Template:Test';
$wgWSStats['ignore_in_url'][] = 'action=edit';

Usage

To retrieve statistics you can use the following parser function:

Ask number of hits for page id 9868:

{{#wsstats:id=9868}}

This returns a number


You can also ask for statistics based on title, instead of page ID's:

Ask number of hits for page with title Main Page:

{{#wsstats:title=Main Page}}

This returns a number


About dates. Dates are in a format of YYYY-MM-DD. Internally WSStats works with Date and Time. This means a date of 2023-10-30 will internally become 2023-10-30 00:00:00. You can also search by date and time. See the examples about this.


Ask number of hits for page ID 714 since start date 2018-09-01:

{{#wsstats:id=714
|start date=2023-09-01
}}

This returns a number


Ask number of hits for page ID 714 since start date 2018-02-01 and end date 2018-09-08:

{{#wsstats:id=714
|start date=2023-02-01|end date=2023-09-08
}}

This returns a number


You can also get statistics based on date and time Get number of hits for page ID 714 from start date 2023-10-30 14:00:00 and end date 2023-10-30 16:00:00:

{{#wsstats:id=714
|start date=2023-10-30 14:00:00
|end date=2023-10-30 16:00:00
}}

This returns a number


Filter results on registered users or anonymous users:

{{#wsstats:id=714
|start date=2023-02-01
|end date=2023-02-08
|type=only anonymous
}}

This returns a number

{{#wsstats:id=714
|start date=2023-02-01
|end date=2023-02-08
|type=only user
}}

This returns a number


Get the top ten pages sorted by hits:

{{#wsstats:stats}}

This returns a table


Get the top ten pages sorted by hits in a date range:

{{#wsstats:stats
|start date=2023-02-01
|end date=2023-02-08
}}

This returns a table from 2018-02-01 00:00:00 up to 2018-02-08 00:00:00 ( so not including 2018-02-08 )


Get the top ten pages sorted by hits and show as CSV:

{{#wsstats:stats
|format=csv
}}

This returns a string with the results comma seperated (e.g. 1230;51,1;17,921)


Get the top ten pages sorted by hits and insert in a WSArrays variable:

{{#wsstats:stats
|format=wsarrays}}
|name=<wsarray key name>
}}

This returns an empty string and sets the WSArray key. Nothing happens when the WSArrays extension is not installed.


Get the result from WSArrays:

{{#caprint:<wsarray key name>}}


New since version 1.0.7:

Get statistics of one page during a time period and limit to 100 results:

{{#wsstats:stats
|id=1
|start date=2023-02-01
|end date=2023-02-08
|limit 100
}}

This returns a table


For all queries you can add a unique identifier to only return unique views:

{{#wsstats:stats
|start date=2023-02-01
|end date=2023-02-08
|unique
}}

This returns a table

{{#wsstats:stats
|unique
}}

This returns a table


For all top ten stats queries you can add limit to get less or more than ten results:

{{#wsstats:stats
|unique
|limit=20
}}

This returns a table

lua functions

New in version 2.0

There are two Lua function you can use.

For the parser function that returns a table ({{#wsstats:stats..}}) you can use wsstats.stats().

For the parser function that returns a number ({{#wsstats:stat..}}) you can use wsstats.stat().

All the arguments are the same as for the parser functions, except:

  • start date = startDate
  • end date = endDate
Example

If you create a Module called WSStats and you add the following content:

local p = {}

--[[
This function returns a Lua table with stats. You can test it in the debug console:
=mw.logObject(p.stats(mw.getCurrentFrame()))
--]]
function p.stats(frame)
  stats = mw.wsstats.stats( frame.args )
  return stats

end

--[[
This function returns an ArrayFunctions export, it requires the ArrayFunctions extension. Example invoke:
{{#af_print:{{#invoke:WSStats|afExportStats}} }}
--]]
function p.afExportStats(frame)
  stats = mw.wsstats.stats( frame.args )
  return mw.af.export(stats)
end

--[[ 
This function returns an integer number of views for a specific page. Example invoke:
{{#invoke:wsstats|stat|id=1|startDate=2023-09-25|endDate=2023-09-26}}
--]]
function p.stat(frame)
  stat = mw.wsstats.stat( frame.args )
  return stat
end

return p

To get views using LUA example :

{{#invoke:WSStats|stat|id=1|startDate=2023-09-25|endDate=2025-03-01}}
Date format to use
Date formats
DateTranslates to
2018-02-01First of February 2018
2018-02-01 11First of February 2018 at 11am
2018-02-01 11:15First of February 2018 at a quarter past eleven in the morning
2018-02-01 14:15:30First of February 2018 at a quarter past two in the afternoon and 30 seconds

The result will be 0 if there are no statistics available.

Version history

  • Version 2.0.3 : Updated LUA docs. REL1_43 Branch added.
  • Version 2.0.2 : Index set on Added. Thanks to shreenivasan from Pegasystems for the Database optimalisation updates.
  • Version 2.0.1 : Fixed sql table https://github.com/WikibaseSolutions/WSStats/pull/8 add indexing to user and page https://github.com/WikibaseSolutions/WSStats/pull/9
  • Version 2.0.0 : REL 1.39 only. Added statistics for Special Pages. Lua equivalent functions for statistics. Special Page added.
  • Version 1.0.8 : Removed global references // last release for MediaWiki Version 1.35.x
  • Version 1.0.7 : Added statistics over time for pages
  • Version 1.0.6 : Fixed path to sql tables
  • Version 1.0.5 : Rewrote database queries to use MW database abstraction layer. extension manifest 2 and all user input is validated.
  • Version 1.0.4 : Security fix! Unhandled user input. Update to 1.0.4 as soon as possible.
  • Version 1.0.3 : Top X list changed as it no longer shows deleted pages
  • Version 1.0.2 : Catched request for title on a non-existing page
  • Version 1.0.1 : Code clean-up and i18n messages added
  • Version 1.0.0 : Added support for setting limit and export as WSArrays
  • Version 0.8.2 : Added support for filtering only unique visitors
  • Version 0.8.1 : adminlinks added
  • Version 0.8.0 : Clean Up
  • Version 0.1.9 : Fetch Title changes
  • Version 0.1.8 : Removed dbprefix class variable
  • Version 0.1.7 : Show top visited pages with date range. Show as csv option
  • Version 0.1.6 : Filter results on user or anonymous
  • Version 0.1.5 : Added more configuration options
  • Version 0.1.3 : Fixed error in MySQL
  • Version 0.1.2 : Skip usergroup results
  • Version 0.1.1 : Initial release
Category:Extensions by Wikibase Solutions/pl
Category:AdminLinks extensions/pl Category:All extensions/pl Category:BeforePageDisplay extensions/pl Category:Extensions by Wikibase Solutions/pl Category:Extensions in GitHub version control/pl Category:Extensions supporting Composer/pl Category:Extensions with manual MediaWiki version Category:GPL licensed extensions/pl Category:LoadExtensionSchemaUpdates extensions/pl Category:ParserFirstCallInit extensions/pl Category:Parser extensions/pl Category:ScribuntoExternalLibraries extensions/pl Category:Stable extensions/pl