Commit e8c28a4a authored by Julien Wajsberg's avatar Julien Wajsberg Committed by Phyks

Add an is_expired column to the model

You should delete your database and let the software recreate it after
this commit. Alternatively, add the `is_expired` column to the flats
parent dc9abadf
......@@ -155,6 +155,11 @@ def import_and_filter(config, load_from_db=False):
with get_session() as session:
# Set is_expired to true for all existing flats.
# This will be set back to false if we find them during importing.
for flat in session.query(flat_model.Flat).all():
flat.is_expired = True;
for status, flats_list in flatten_flats_by_status.items():
# Build SQLAlchemy Flat model objects for every available flat
flats_objects = {
......@@ -178,6 +183,10 @@ def import_and_filter(config, load_from_db=False):
flat_object.status = each.status
# Every flat we fetched isn't expired
flat_object.is_expired = False
# For each flat already in the db, merge it (UPDATE)
# instead of adding it
......@@ -11,7 +11,7 @@ import enum
import arrow
from sqlalchemy import (
Column, DateTime, Enum, Float, SmallInteger, String, Text, inspect
Boolean, Column, DateTime, Enum, Float, SmallInteger, String, Text, inspect
from sqlalchemy.orm import validates
......@@ -83,6 +83,7 @@ class Flat(BASE):
merged_ids = Column(MagicJSON)
notes = Column(Text)
notation = Column(SmallInteger, default=0)
is_expired = Column(Boolean, default=False)
# Flatisfy data
# TODO: Should be in another table with relationships
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment