Toggle navigation
Home
New Query
Recent Queries
Discuss
Database tables
Database names
MediaWiki
Wikibase
Replicas browser and optimizer
Login
History
Fork
Fork of
Wikidata - English descriptions starting with "a .."
by
Jura1
This query is marked as a draft
This query has been published
by
Hasley
.
Toggle Highlighting
SQL
query_block_weekly=''' SELECT WEEKofyear(from_unixtime(UNIX_timestamp(log_timestamp,'yyyyMMddHHmmss'))) AS week_n, COUNT(1) AS blocks FROM wmf_raw.mediawiki_logging WHERE snapshot ='{SNAPSHOT}' AND log_type = 'block' AND wiki_db='ptwiki' AND log_action IN ('block','reblock') AND substr(log_timestamp,1,8) BETWEEN '{START_YYYYMMDD}' AND '{END_YYYYMMDD}' GROUP BY WEEKofyear(from_unixtime(UNIX_timestamp(log_timestamp,'yyyyMMddHHmmss'))) ORDER BY week_n LIMIT 100000 ''' df_block_weekly=hive.run(query_block_weekly.format(SNAPSHOT=snapshot, START_YYYYMMDD=start_date_YYYYMMDD, END_YYYYMMDD=end_date_YYYYMMDD)) df_block_weekly_pre_1_year=hive.run(query_block_weekly.format(SNAPSHOT=snapshot, START_YYYYMMDD=lastyear_start_date_YYYYMMDD, END_YYYYMMDD=lastyear_end_date_YYYYMMDD)) df_block_weekly_pre_2_years=hive.run(query_block_weekly.format(SNAPSHOT=snapshot, START_YYYYMMDD=last2years_start_date_YYYYMMDD, END_YYYYMMDD=last2years_end_date_YYYYMMDD)) fig, ax = plt.subplots(nrows=2, ncols=1,figsize=(16,12)) fig.tight_layout(pad=1.08, w_pad=0.5, h_pad=6) ax[0].set_title('Ptwiki Weekly Blocks',fontweight="bold",fontsize = 16,y=1.08) ax[0].set_xlabel('Week', fontsize = 16) ax[0].set_ylabel('Blocks', fontsize = 16) ax[0].plot(df_block_weekly['week_n'], df_block_weekly['blocks'], 'o-',label='Year 2021') ax[0].plot(df_block_weekly_pre_1_year['week_n'], df_block_weekly_pre_1_year['blocks'], 'o--',label='Year 2020') ax[0].plot(df_block_weekly_pre_2_years['week_n'], df_block_weekly_pre_2_years['blocks'], ':',label='Year 2019') ax[0].set_xlim(1,52) ax[0].set_ylim(0,14000) ax[0].vlines(40, 0, 140000, colors='k', linestyles='dashdot', label='Turned off') ax[0].legend(loc='upper right') ax[0].yaxis.set_major_formatter(thousand_formatter) ax2 = ax[0].twiny() # instantiate a second axes that shares the same x-axis ax2.set_xlim(0,12) ax2.set_xticklabels(['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']) ax2.set_xticks([0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5]) ax2.tick_params(length=0) ax2.set_xlabel('Month',fontsize=16) miloc = plt.MultipleLocator(1) ax2.xaxis.set_minor_locator(miloc) ax2.grid(axis='x', which='minor') ax[1].set_title('Ptwiki Weekly Blocks',fontweight="bold",fontsize = 16,y=1.08) ax[1].set_xlabel('Week',fontsize = 16) ax[1].set_ylabel('Blocks',fontsize = 16) ax[1].set_xlim(1,52) ax[1].set_ylim(0,4000) ax[1].vlines(40, 0, 4000, colors='k', linestyles='dashdot', label='Turned off') ax3=ax[1].twiny() ax3.set_xlim(0,12) ax3.set_xticklabels(['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']) ax3.set_xticks([0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5]) ax3.tick_params(length=0) ax3.set_xlabel('Month',fontsize=16) ax3.xaxis.set_minor_locator(miloc) ax3.grid(axis='x', which='minor') ax[1].plot(df_block_weekly['week_n'], df_block_weekly['blocks'], 'o-',label='Year 2021') ax[1].plot(df_block_weekly_pre_1_year['week_n'], df_block_weekly_pre_1_year['blocks'], 'o--',label='Year 2020') ax[1].legend(loc='upper right') plt.show()
By running queries you agree to the
Cloud Services Terms of Use
and you irrevocably agree to release your SQL under
CC0 License
.
Submit Query
Stop Query
All SQL code is licensed under
CC0 License
.
Checking query status...