Skip to content

Commit

Permalink
Merge pull request #270 from investigativedata/develop
Browse files Browse the repository at this point in the history
v0.6.7
  • Loading branch information
simonwoerpel committed Jun 18, 2024
2 parents fa075d1 + dc74b70 commit aedf98a
Show file tree
Hide file tree
Showing 12 changed files with 432 additions and 585 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.6.6
current_version = 0.6.7
commit = True
tag = True
message = 🔖 Bump version: {current_version} → {new_version}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push release
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
# platforms: linux/amd64,linux/arm64
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.6
0.6.7
2 changes: 1 addition & 1 deletion ftmq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ftmq.query import Query

__version__ = "0.6.6"
__version__ = "0.6.7"
__all__ = ["Query"]
13 changes: 5 additions & 8 deletions ftmq/model/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from ftmq.enums import Properties
from ftmq.model.mixins import BaseModel
from ftmq.types import CE, CEGenerator, DateLike, Frequencies
from ftmq.util import get_country_name
from ftmq.types import CE, CEGenerator, Frequencies
from ftmq.util import get_country_name, get_year


class Schema(BaseModel):
Expand Down Expand Up @@ -39,8 +39,8 @@ class Schemata(BaseModel):


class Coverage(BaseModel):
start: DateLike | None = None
end: DateLike | None = None
start: str | None = None
end: str | None = None
frequency: Frequencies | None = "unknown"
countries: list[str] | None = []
schedule: str | None = None
Expand All @@ -50,10 +50,7 @@ def years(self) -> tuple[int | None, int | None]:
"""
Return min / max year extend
"""
return (
self.start.year if self.start else None,
self.end.year if self.end else None,
)
return get_year(self.start), get_year(self.end)


class DatasetStats(BaseModel):
Expand Down
9 changes: 3 additions & 6 deletions ftmq/store/sql.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from collections import defaultdict
from datetime import date
from decimal import Decimal

from anystore.util import clean_dict
Expand Down Expand Up @@ -64,17 +63,15 @@ def stats(self, query: Q | None = None) -> DatasetStats:
):
if country is not None:
c.intervals_countries[country] = count

stats = c.export()
for start, end in self.store._execute(query.sql.date_range, stream=False):
if start:
stats.coverage.start = date.fromisoformat(start)
stats.coverage.start = start
if end:
stats.coverage.end = date.fromisoformat(end)
stats.coverage.end = end
break

for res in self.store._execute(query.sql.countries, stream=False):
stats.coverage.countries.append(res)

for res in self.store._execute(query.sql.count, stream=False):
for count in res:
stats.entity_count = count
Expand Down
2 changes: 0 additions & 2 deletions ftmq/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from collections.abc import Generator
from datetime import date, datetime
from pathlib import Path
from typing import Any, Literal, TypeAlias

Expand All @@ -27,7 +26,6 @@
Frequencies: TypeAlias = Literal[tuple(f.name for f in enums.Frequencies)]

PathLike: TypeAlias = str | os.PathLike[str] | Path
DateLike: TypeAlias = date | datetime

__all__ = [
"BytesGenerator",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@investigativedata/ftmq",
"version": "0.6.6",
"version": "0.6.7",
"description": "javascript interface for ftmq",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
615 changes: 266 additions & 349 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ftmq"
version = "0.6.6"
version = "0.6.7"
description = "followthemoney query dsl and io helpers"
authors = ["Simon Wörpel <simon.woerpel@pm.me>"]
license = "MIT"
Expand Down Expand Up @@ -39,7 +39,7 @@ alephclient = "^2.4.1"
pycountry = ">=23.12.11,<25.0.0"
urllib3 = "<3"
nomenklatura = ">3.10,<3.11"
anystore = "^0.1.3"
anystore = "^0.1.5"
pantomime = "^0.6.1"

[tool.poetry.group.dev.dependencies]
Expand Down
358 changes: 149 additions & 209 deletions requirements.txt

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions tests/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ def test_coverage(fixtures_path: Path):
for proxy in smart_read_proxies(fixtures_path / "donations.ijson"):
c.collect(proxy)

start = date(2002, 7, 4)
end = date(2011, 12, 29)
result = {
"coverage": {
"start": start,
"end": end,
"start": "2002-07-04",
"end": "2011-12-29",
"frequency": "unknown",
"countries": ["cy", "de", "gb", "lu"],
"schedule": None,
Expand Down

0 comments on commit aedf98a

Please sign in to comment.