Remove depreciated method ask_byCountry

Signed-off-by: Richard Gregory <richardgrecoson@gmail.com>
This commit is contained in:
Richard Gregory 2020-09-15 21:26:38 +01:00
commit 30dff6e864
5 changed files with 8 additions and 45 deletions

View file

@ -30,12 +30,12 @@ Create a file name myconfig.cfg. Copy the content of myconfig.cfg.example and pa
In your terminal, run enter `jupyter notebook`. A new window should open in your browser at `http://localhost:8888`
For a sample, open a new terminal in the jupyter web app. Run `python fedora_join_example.py`. You should see an image like the one below open in another window:
![sample-plot](fedora-commops/geofp/raw/master/f/doc/img/sample-plot.png)
For samples, open a new terminal in the jupyter web app. Run `python fedora_all_example.py` to see a plot map and heat map of all active users in the year 2020.
![sample-plot-fedorians](/fedora-commops/geofp/raw/master/f/doc/img/sample-plot-active-members-by-country.png)
`python fedora_join_example.py` to see an example plot and heat map of Fedora Join team.
![sample-plot-fedorians](/fedora-commops/geofp/raw/master/f/doc/img/sample-plot-fedora-join-team.png)
### ToDos:
* A (nice) jupyter-notebook with examples of use
* Heatmap
* virtualenv
* Error Handling

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View file

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Before After
Before After

View file

@ -60,43 +60,6 @@ class geofp(object):
if active_date!=None:
self.members=self.members[(self.members.last_seen >= active_date) & (self.members.status == 'active')]
return self.members
def ask_byCountry(self,since=None):
''' Depreciated'''
print("Go for coffee...")
#get all the msg since "since variable" to today
baseurl = "https://apps.fedoraproject.org/datagrepper/raw?topic=org.fedoraproject.prod.askbot.post.edit"
users=[]
if since!=None:
dlt= (datetime.now() - since).total_seconds()
params={'rows_per_page':100,'delta':dlt,'size':'small', 'page':1}
else:
params={'page':1,'rows_per_page':100, 'size':'small'}
results = requests.get(baseurl,params=params).json()
for i in range(results['pages']):
for msg in results['raw_messages']:
if msg['msg']['created']:
users.append(msg['msg']['agent'])
params['page']=i+1
rst= requests.get(baseurl,params=params)
if rst == None:
break
else:
results= rst.json()
#Ask to fas for all the users
GeoData={}
Members=Counter(users)
for member in Members.keys():
gd=self.fas.people_by_key(key=u'username', search=member )
GeoData.update(gd)
#To pandas DataFrame
self.members=pd.DataFrame.from_dict(GeoData, orient='index')
self.members['last_seen']=pd.to_datetime(self.members.last_seen)
self.members['ask_updates']=pd.Series(Members) #experimental
return self.members
def plot_world(self,title='Map', label='# Elements', filename='base_file.svg', save=True):
'''plot a fancy map with heat information '''

View file

@ -11,8 +11,8 @@ from datetime import datetime
if __name__=='__main__':
gp=geofp('myconfig.cfg')
df=gp.ask_byCountry(datetime(2017,4,15))
df=gp.all_fedorians()
print("Follow the links")
print(gp.plot_world2(title='Fedora Ask questions by country since 04/15/2017',label='questions by country',filename='Fedora-Ask', notebook=False))
print(gp.plot_world2(title='Map of All Fedorians By Country of Origin',label='fedorians by country',filename='Fedorians', notebook=False))
df.to_csv('AskFedora.csv')
print(gp.plot_heat(title='Fedora Ask questions by country since 04/15/2017',label='questions by country',filename='Fedora-Ask', notebook=False))
print(gp.plot_heat(title='Map of All Fedorians By Country of Origin',label='fedorians by country',filename='Fedorians', notebook=False))