Fix bug when application foreground list was empty
parent
12ceb87090
commit
2548539dc4
|
@ -33,24 +33,27 @@ genre_catalogue <- data.frame()
|
||||||
catalogue_source <- snakemake@params[["catalogue_source"]]
|
catalogue_source <- snakemake@params[["catalogue_source"]]
|
||||||
update_catalogue_file <- snakemake@params[["update_catalogue_file"]]
|
update_catalogue_file <- snakemake@params[["update_catalogue_file"]]
|
||||||
scrape_missing_genres <- snakemake@params[["scrape_missing_genres"]]
|
scrape_missing_genres <- snakemake@params[["scrape_missing_genres"]]
|
||||||
|
apps_with_genre <- data.frame(matrix(ncol=length(colnames(apps)) + 1,nrow=0, dimnames=list(NULL, c(colnames(apps), "genre"))))
|
||||||
|
|
||||||
if(catalogue_source == "GOOGLE"){
|
if(nrow(apps) > 0){
|
||||||
apps_with_genre <- apps %>% mutate(genre = NA_character_)
|
if(catalogue_source == "GOOGLE"){
|
||||||
} else if(catalogue_source == "FILE"){
|
apps_with_genre <- apps %>% mutate(genre = NA_character_)
|
||||||
genre_catalogue <- read.csv(snakemake@params[["catalogue_file"]], colClasses = c("character", "character"))
|
} else if(catalogue_source == "FILE"){
|
||||||
apps_with_genre <- left_join(apps, genre_catalogue, by = "package_name")
|
genre_catalogue <- read.csv(snakemake@params[["catalogue_file"]], colClasses = c("character", "character"))
|
||||||
}
|
apps_with_genre <- left_join(apps, genre_catalogue, by = "package_name")
|
||||||
|
}
|
||||||
|
|
||||||
if(catalogue_source == "GOOGLE" || (catalogue_source == "FILE" && scrape_missing_genres)){
|
if(catalogue_source == "GOOGLE" || (catalogue_source == "FILE" && scrape_missing_genres)){
|
||||||
apps_without_genre <- (apps_with_genre %>% filter(is.na(genre)) %>% distinct(package_name))$package_name
|
apps_without_genre <- (apps_with_genre %>% filter(is.na(genre)) %>% distinct(package_name))$package_name
|
||||||
updated_apps <- get_genre(apps_without_genre)
|
updated_apps <- get_genre(apps_without_genre)
|
||||||
apps_with_genre <- left_join(apps_with_genre, updated_apps, by = "package_name") %>%
|
apps_with_genre <- left_join(apps_with_genre, updated_apps, by = "package_name") %>%
|
||||||
mutate(genre = coalesce(genre.x, genre.y)) %>%
|
mutate(genre = coalesce(genre.x, genre.y)) %>%
|
||||||
select(-genre.x, -genre.y)
|
select(-genre.x, -genre.y)
|
||||||
|
|
||||||
if(update_catalogue_file){
|
if(update_catalogue_file){
|
||||||
genre_catalogue <- bind_rows(genre_catalogue, updated_apps) %>% distinct()
|
genre_catalogue <- bind_rows(genre_catalogue, updated_apps) %>% distinct()
|
||||||
write.csv(genre_catalogue, file = snakemake@params[["catalogue_file"]], row.names = FALSE)
|
write.csv(genre_catalogue, file = snakemake@params[["catalogue_file"]], row.names = FALSE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue