Skip to content

Commit

Permalink
Merge pull request #21 from qld-gov-au/develop
Browse files Browse the repository at this point in the history
Develop to master - update database setup syntax
  • Loading branch information
ThrawnCA authored Feb 1, 2025
2 parents c2520e3 + 26def3b commit bee05d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ jobs:
fail-fast: false
matrix:
include:
- ckan-version: "2.11"
- ckan-version: '2.11'
solr-version: 9
experimental: false
- ckan-version: "2.10"
- ckan-version: '2.10'
solr-version: 8
experimental: false
- ckan-version: "2.9"
- ckan-version: '2.9'
solr-version: 8
experimental: false
- ckan-version: "master"
- ckan-version: 'master'
solr-version: 9
experimental: true #master is unstable, good to know if we are compatible or not

name: Test on CKAN ${{ matrix.ckan-version }}
name: ${{ matrix.experimental && '**Fail_Ignored** ' || '' }} CKAN ${{ matrix.ckan-version }}
runs-on: ubuntu-latest
container: drevops/ci-runner:23.12.0
env:
Expand Down
15 changes: 7 additions & 8 deletions ckanext/report/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
import logging
import json

from sqlalchemy import types, Table, Column, Index, MetaData
from sqlalchemy.orm import mapper
from sqlalchemy import types, Table, Column, Index
from sqlalchemy.ext.declarative import declarative_base

from ckan import model
from collections import OrderedDict
from ckan.model.meta import metadata

log = logging.getLogger(__name__)

__all__ = ['DataCache', 'data_cache_table', 'init_tables']

metadata = MetaData()

data_cache_table = Table(
'data_cache', metadata,
Column('id', types.UnicodeText, primary_key=True,
Expand All @@ -28,8 +27,10 @@
Index('idx_data_cache_object_id_key', data_cache_table.c.object_id,
data_cache_table.c.key)

Base = declarative_base(metadata=metadata)


class DataCache(object):
class DataCache(Base):
"""
DataCache provides simple caching of pre-calculated values for queries that
would take too long to run in real time. It allows background tasks to
Expand Down Expand Up @@ -60,6 +61,7 @@ class DataCache(object):
which happens to be refreshed regularly, so suitable for storage in the
main application db, rather than any volatile external cache.
"""
__table__ = data_cache_table

def __init__(self, **kwargs):
for k, v in kwargs.items():
Expand Down Expand Up @@ -124,8 +126,5 @@ def set(cls, object_id, key, value, convert_json=False):
return item.created


mapper(DataCache, data_cache_table)


def init_tables():
metadata.create_all(model.meta.engine)

0 comments on commit bee05d9

Please sign in to comment.