[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://codeberg.org/IzzyOnDroid/.profile/src/branch/master/CODE_OF_CONDUCT.md)

This repository holds some statistics from IzzyOnDroid, as well as a wrapper around [iod-stats-builder](https://codeberg.org/IzzyOnDroid/iod-stats-builder/) used to create and maintain them.

## APK Download Statistics
Download statistics for [our Android App Repo](https://apt.izzysoft.de/fdroid) are provided in JSON format, stored inside the `apk_downloads` directory, grouped by years. Each JSON file represents a week, and again is partitioned by day. So what you will find there is, for each app downloaded, daily stats. For more info, check [iod-stats-builder](https://codeberg.org/IzzyOnDroid/iod-stats-builder/).

Instead of the default workflow, this repo uses the `scripts/iod_dl_stats` wrapper, which expects `iod-stats-builder` present next to it (same parent directory as `iodstats` uses), but this can be adjusted in the config section at the start of the script. Processing is then done automatically by simply calling the script, no parameters required:

Logs are pre-processed by `scripts/iod_dl_stats` and fed to the parser. Pre-processing here means grepping the logs for successful APK downloads, and only feed matching lines to the parser (which speeds up processing by factor ~20 as opposed to having the parser processing the full log: a ~2 GB Apache log is processed in less than a minute on our small 4-core VM this way, even while under load). This wrapper script also takes care for file naming and git handling; just take a look inside it, it should be pretty much self explaining.

The weekly processing is based on the fact that Apache log files of the server are rotated weekly, and thus the rotated log of the previous week will be processed.

The only requirements here (apart from what can be expected to be present, like `grep` and of course `iod-stats-builder`) are Bash and Python3.


## App Statistics
A second script in this repo is `scripts/appstats.php`. Based on the information in our database (where the JSON index of [our Android App Repo](https://apt.izzysoft.de/fdroid) is loaded into, for faster processing), this generates 3 files:

* `appcategories.json`: all apps with the categories they belong to. This is an object with the mapping `str packageName => list categories`.
* `appnames.json`: all apps with their display names. Again an object, with the mapping `str packageName => str displayName`
* `new_apps.csv`: a comma-separated list, with the fields `package_name`, `label` (aka DisplayName), `date` the given app was added (in the format `YYYY-MM-DD`)

With our setup, those files are generated in the `appstats/` directory of this repository. Configuration takes place in `scripts/appstats_config.json`, an example configuration is provided as `scripts/appstats_config.json.example`.

These data serve as the input for our monthly reports.


## License
Unless mentioned otherwise (check e.g. with the SPDX headers inside the files), all scripts in this repository are licensed as AGPL-3.0-or-later (see the `LICENSE.txt`):

> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
>
> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [GNU Affero General Public License](https://www.gnu.org/licenses/agpl.txt) for more details.


## Funding

This project is funded through [NGI Mobifree Fund](https://nlnet.nl/mobifree), a fund established by [NLnet](https://nlnet.nl) with financial support from the European Commission's [Next Generation Internet](https://ngi.eu) program. Learn more at the [NLnet project page](https://nlnet.nl/project/IzzyOnDroid).

<p align="center"><a href="https://nlnet.nl"><img src="https://nlnet.nl/logo/banner.png" alt="NLnet foundation logo" height="50px" /></a>     <a href="https://nlnet.nl/mobifree/"><img src="https://nlnet.nl/image/logos/NGI_Mobifree_tag.svg" height="50px" /></a></p>
