Pageviews: Relecture du code
This commit is contained in:
parent
e438d72e7c
commit
61e9ce3334
|
@ -188,19 +188,14 @@ def wikimedia_mean_article_views(site, article):
|
||||||
accumulator[datemonth].append(views)
|
accumulator[datemonth].append(views)
|
||||||
|
|
||||||
for datemonth, value in accumulator.items():
|
for datemonth, value in accumulator.items():
|
||||||
accumulator[datemonth] = (
|
accumulator[datemonth] = sum(value) / len(value) if value else 0
|
||||||
sum(accumulator[datemonth])
|
|
||||||
/ len(accumulator[datemonth])
|
|
||||||
) if accumulator[datemonth] else 0
|
|
||||||
|
|
||||||
# Fait une moyenne glissante sur 7 jours
|
# Rassemble les valeurs moyennes pour chaque jour dans l'ordre de l'année
|
||||||
days = [item[1] for item in sorted(
|
return [item[1] for item in sorted(
|
||||||
list(accumulator.items()),
|
list(accumulator.items()),
|
||||||
key=lambda x: x[0]
|
key=lambda x: x[0]
|
||||||
)]
|
)]
|
||||||
|
|
||||||
return days
|
|
||||||
|
|
||||||
|
|
||||||
def create_year_plot():
|
def create_year_plot():
|
||||||
"""
|
"""
|
||||||
|
@ -257,7 +252,8 @@ dénombrée comme une visite sur la page canonique.
|
||||||
|
|
||||||
data = wikimedia_mean_article_views(site, canonical_article)
|
data = wikimedia_mean_article_views(site, canonical_article)
|
||||||
ax.plot(year_smooth_gaussian(data, 10), label=canonical_article)
|
ax.plot(year_smooth_gaussian(data, 10), label=canonical_article)
|
||||||
ax.set_ylabel('Vues par jour')
|
|
||||||
|
ax.set_ylabel('Vues par jour')
|
||||||
|
|
||||||
fig.legend()
|
fig.legend()
|
||||||
fig.autofmt_xdate()
|
fig.autofmt_xdate()
|
||||||
|
|
Loading…
Reference in New Issue