Reset top 10 list to begin at 1

This commit is contained in:
benmiroglio 2019-06-05 06:54:49 -07:00
Родитель 33e5de0b0b
Коммит b74744d3d2
3 изменённых файлов: 30 добавлений и 47 удалений

Просмотреть файл

@ -114,7 +114,6 @@ def get_user_demo_metrics(addons_expanded):
ct_dist = ct_dist.na.fill(0).select("addon_id", source_map(ct_dist, "country_pct"))
combined_dist = os_dist.join(ct_dist, on="addon_id", how="outer")
return combined_dist
@ -247,9 +246,9 @@ def get_top_10_coinstalls(addons_expanded_day):
.filter("rn BETWEEN 1 and 10") # ignore 0th addon (where coaddon==addon_id)
.groupby("addon_id")
.agg(
F.collect_list(
F.concat((F.col("rn") - F.lit(1)), F.lit("="), "coaddon")
).alias("top_10_coinstalls")
F.collect_list(F.concat(F.col("rn"), F.lit("="), "coaddon")).alias(
"top_10_coinstalls"
)
)
.rdd.map(format_row)
.toDF()

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -328,63 +328,47 @@ def test_top_ten_coinstalls(addons_expanded_day, spark):
output = df_to_json(get_top_10_coinstalls(addons_expanded_day))
expected = [
{
"addon_id": u"baidu-code-update@mozillaonline.com",
"addon_id": "baidu-code-update@mozillaonline.com",
"top_10_coinstalls": {"1": "non-system-addon2", "2": "non-system-addon1"},
},
{
"addon_id": "screenshots@mozilla.org",
"top_10_coinstalls": {
u"0": u"non-system-addon2",
u"1": u"non-system-addon1",
"1": "hotfix-update-xpi-intermediate@mozilla.com",
"2": "non-system-addon1",
},
},
{
"addon_id": u"screenshots@mozilla.org",
"addon_id": "non-system-addon1",
"top_10_coinstalls": {"1": "non-system-addon1", "2": "non-system-addon2"},
},
{
"addon_id": "hotfix-update-xpi-intermediate@mozilla.com",
"top_10_coinstalls": {"1": "non-system-addon1", "2": "non-system-addon2"},
},
{
"addon_id": "fxmonitor@mozilla.org",
"top_10_coinstalls": {
u"0": u"hotfix-update-xpi-intermediate@mozilla.com",
u"1": u"non-system-addon1",
"1": "non-system-addon1",
"2": "hotfix-update-xpi-intermediate@mozilla.com",
},
},
{
"addon_id": u"non-system-addon1",
"top_10_coinstalls": {
u"0": u"non-system-addon1",
u"1": u"non-system-addon2",
},
"addon_id": "non-system-addon2",
"top_10_coinstalls": {"1": "non-system-addon2", "2": "non-system-addon1"},
},
{
"addon_id": u"hotfix-update-xpi-intermediate@mozilla.com",
"top_10_coinstalls": {
u"0": u"non-system-addon1",
u"1": u"non-system-addon2",
},
"addon_id": "formautofill@mozilla.org",
"top_10_coinstalls": {"1": "non-system-addon1", "2": "non-system-addon2"},
},
{
"addon_id": u"fxmonitor@mozilla.org",
"top_10_coinstalls": {
u"0": u"non-system-addon1",
u"1": u"hotfix-update-xpi-intermediate@mozilla.com",
},
},
{
"addon_id": u"non-system-addon2",
"top_10_coinstalls": {
u"0": u"non-system-addon2",
u"1": u"non-system-addon1",
},
},
{
"addon_id": u"formautofill@mozilla.org",
"top_10_coinstalls": {
u"0": u"non-system-addon1",
u"1": u"non-system-addon2",
},
},
{
"addon_id": u"webcompat@mozilla.org",
"top_10_coinstalls": {
u"0": u"non-system-addon1",
u"1": u"non-system-addon2",
},
"addon_id": "webcompat@mozilla.org",
"top_10_coinstalls": {"1": "non-system-addon1", "2": "non-system-addon2"},
},
]
assert output == expected
def test_engagement_metrics(addons_expanded_day, main_summary_day, spark):
"""