Module: MediaWiki::Query::Lists::RecentChanges
- Includes:
- Users
- Included in:
- MediaWiki::Query::Lists
- Defined in:
- lib/mediawiki/query/lists/recent_changes.rb
Instance Method Summary collapse
-
#get_recent_changes(user = nil, start = nil, stop = nil, limit = @query_limit_default) ⇒ Array<Hash<Symbol, Any>>
Gets the RecentChanges log.
-
#get_recent_deleted_revisions(user = nil, start = nil, stop = nil, limit = @query_limit_default) ⇒ Array<Hash>
Gets the recent deleted revisions.
Methods included from Users
#get_contrib_count, #get_full_watchlist, #get_registration_time, #get_user_contributions, #get_user_gender, #get_usergroups, #get_userlists, #get_userrights
Instance Method Details
#get_recent_changes(user = nil, start = nil, stop = nil, limit = @query_limit_default) ⇒ Array<Hash<Symbol, Any>>
Gets the RecentChanges log.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mediawiki/query/lists/recent_changes.rb', line 19 def get_recent_changes(user = nil, start = nil, stop = nil, limit = @query_limit_default) prop = 'user|comment|parsedcomment|timestamp|title|ids|sha1|sizes|redirect|flags|loginfo' rights = get_userrights patrol = false if rights != false && rights.include?('patrol') prop << '|patrolled' patrol = true end params = { action: 'query', list: 'recentchanges', rcprop: prop, rclimit: get_limited(limit) } params[:rcuser] = user unless user.nil? params[:rcstart] = start.xmlschema unless start.nil? params[:rcend] = stop.xmlschema unless stop.nil? post(params)['query']['recentchanges'].collect do |change| old_length = change['oldlen'] new_length = change['newlen'] diff_length = new_length - old_length hash = { type: change['type'], title: change['title'], revid: change['revid'], old_revid: change['old_revid'], rcid: change['rcid'], user: change['user'], old_length: old_length, new_length: new_length, diff_length: diff_length, timestamp: DateTime.xmlschema(change['timestamp']), comment: change['comment'], parsed_comment: change['parsedcomment'], sha: change['sha1'] } hash[:new] = change.key?('new') hash[:minor] = change.key?('minor') hash[:bot] = change.key?('bot') hash[:patrolled] = change.key?('patrolled') if patrol if change['type'] == 'log' hash[:log_type] = change['logtype'] hash[:log_action] = change['logaction'] hash[:logid] = change['logid'] end hash end end |
#get_recent_deleted_revisions(user = nil, start = nil, stop = nil, limit = @query_limit_default) ⇒ Array<Hash>
Gets the recent deleted revisions.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/mediawiki/query/lists/recent_changes.rb', line 78 def get_recent_deleted_revisions(user = nil, start = nil, stop = nil, limit = @query_limit_default) prop = 'revid|parentid|user|comment|parsedcomment|minor|len|sh1|tags' params = { action: 'query', list: 'deletedrevs', drprop: prop, drlimit: get_limited(limit) } params[:drstart] = start.xmlschema unless start.nil? params[:drend] = stop.xmlschema unless stop.nil? post(params)['query']['deletedrevs'].collect do |rev| r = rev['revisions'][0] hash = { timestamp: DateTime.xmlschema(r['timestamp']), user: r['user'], comment: r['comment'], title: rev['title'] } hash end end |