gaza-stats/README.md

59 lines
2.7 KiB
Markdown

# gaza-stats
A Clojure library designed to explore donations data for people in Gaza whose accounts have been verified by the [Gaza Verified volunteers](gaza-verified.org/team/).
![Graph of donations between April 2024 and today](all-donations.png)
## Dependencies
* [Leiningen](https://leiningen.org/)
* [Clojure](https://clojure.org/)
* [cljc.java-time](https://github.com/henryw374/cljc.java-time)
* [SQL Korma](https://web.archive.org/web/20190223025406/http://www.sqlkorma.com/)
* [clj-xchart](https://github.com/hypirion/clj-xchart)
## Usage
This is a very experimental, unfinished and unpolished library designed for use with leiningen. To use, clone this repository, connect to the directory into which you cloned it, and type `lein repl`.
At present two useful functions are implemented:
### `(total-donations-by-weeks start-date end-date)`
Return a list of pairs [java.time.LocalDate date, float amount] representing
the total of donations made between `start-date` and `end-date`. Arguments may
be supplied as `java.time.LocalDate` objects, or as strings in the format
`yyyy-mm-dd`. If `end-date` is not supplied, data for a single week will be
returned.
### `chart-total-donations-by-weeks`
Create and return an XY chart of data on total donations made between
`start-date` and `end-date`. Arguments may be supplied as
`java.time.LocalDate` objects, or as strings in the format `yyyy-mm-dd`.
### Viewing charts
In your REPL, invoke `(require '[com.hypirion.clj-xchart :refer [view]])`. You
can then invoke `view` on a chart returned by the above function, for example:
```clojure
(view (chart-total-donations-by-weeks "2024-04-01" "2026-09-20"))
```
## NOTE: Data
This code is designed to explore data in a [SQLite](https://www.sqlite.org/) database which it expects to be called `app.db` and find in its `resources` directory. This database is not included in this repository but may be downloaded from [here](https://gaza.onl/app.db).
## NOTE: Use of SQL Korma
I used SQL Korma in this project because I know it and I like it, but it is no longer maintained and its website is no longer online. The last version I could find on the Internet Archive is [here](https://web.archive.org/web/20190223025406/http://www.sqlkorma.com/). The source code is on [Github](https://github.com/korma/Korma). It might be better to rewrite so as not to use it, especially given that (at present) the SQL usage is trivial.
## License
Copyright © 2026 Simon Brooke.
This program and the accompanying materials are made available under the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available
at https://www.gnu.org/software/classpath/license.html.