Documentation for modules

Attention! This module is copied from Wikipedia:Module:Analytics, do not modify it! To ensure Appropedia's long-term sustainability, all modules (except Module:Appropedia) are copied from Wikipedia and should only be edited to keep them up to date with the latest version.

See Wikipedia:Module:Analytics for this module's documentation.

See also

-- Module:Analytics gets and displays various analytics given off by Extension:Analytics
-- Author: Felipe Schenone (User:Sophivorus)
-- License: GNU General Public License 3 or later (http://www.gnu.org/licenses/gpl-3.0.html)
local Analytics = {}

function Analytics.viewCount( frame )
	local count = 0
	local params = frame.args
	local data = mw.ext.analytics.getViewsData( params )
	for k, v in pairs( data ) do
		count = count + v
	end
	return count
end

function Analytics.editCount( frame )
	local count = 0
	local params = frame.args
	local data = mw.ext.analytics.getEditsData( params )
	for k, v in pairs( data ) do
		count = count + v
	end
	return count
end

function Analytics.views( frame )
	local params = frame.args
	local data = mw.ext.analytics.getViewsData( params )

	-- Make the table header
	local th1 = mw.html.create( 'th' ):wikitext( 'Date' )
	local th2 = mw.html.create( 'th' ):wikitext( 'Views' )
	local thr = mw.html.create( 'tr' ):node( th1 ):node( th2 )
	local html = mw.html.create( 'table' ):addClass( 'wikitable sortable' ):node( thr )

	-- Make the table rows
	local td1, td2, tdr
	for k, v in pairs( data ) do
		td1 = mw.html.create( 'td' ):wikitext( k )
		td2 = mw.html.create( 'td' ):wikitext( v )
		tdr = mw.html.create( 'tr' ):node( td1 ):node( td2 )
		html:node( tdr )
	end

	return html
end

function Analytics.edits( frame )
	local params = frame.args
	local data = mw.ext.analytics.getEditsData( params )

	-- Make the table header
	local th1 = mw.html.create( 'th' ):wikitext( 'Date' )
	local th2 = mw.html.create( 'th' ):wikitext( 'Edits' )
	local thr = mw.html.create( 'tr' ):node( th1 ):node( th2 )
	local html = mw.html.create( 'table' ):addClass( 'wikitable sortable' ):node( thr )

	-- Make the table rows
	local td1, td2, tdr
	for k, v in pairs( data ) do
		td1 = mw.html.create( 'td' ):wikitext( k )
		td2 = mw.html.create( 'td' ):wikitext( v )
		tdr = mw.html.create( 'tr' ):node( td1 ):node( td2 )
		html:node( tdr )
	end

	return html
end

return Analytics
Cookies help us deliver our services. By using our services, you agree to our use of cookies.