backend/model/
entity.rs

1//! Contains all entities used in `PermaplanT`.
2//!
3//! The fill & error ratios in the file can be calculated and updated automatically
4//! via the script in /tools/update-fill-error-ratio/update-fill-error-ratio.py (usage in respective README)
5//!
6//! Latest script run was on 07.07.2026
7//! Git SHA of the scraper-data commit used: 4eeed7ea0fda9fa6f3a6771d4816ab8330bf81e8
8
9pub mod application_settings_impl;
10pub mod areas;
11pub mod areas_impl;
12pub mod base_layer_images;
13pub mod base_layer_images_impl;
14pub mod drawing_properties;
15pub mod drawing_properties_impl;
16pub mod drawings;
17pub mod drawings_impl;
18pub mod guided_tour_impl;
19pub mod layers;
20pub mod layers_impl;
21pub mod map_collaborator_impl;
22pub mod map_impl;
23pub mod plant_layer;
24pub mod plantings;
25pub mod plantings_impl;
26pub mod plants_impl;
27pub mod seed_impl;
28pub mod timeline;
29
30use chrono::NaiveDate;
31use chrono::NaiveDateTime;
32
33use diesel::AsChangeset;
34use diesel::QueryableByName;
35use diesel::{Identifiable, Insertable, Queryable};
36use postgis_diesel::types::Point;
37use postgis_diesel::types::Polygon;
38use uuid::Uuid;
39
40use crate::schema::{
41    application_settings, guided_tour_progress, guided_tour_states, map_collaborators, maps,
42    plants, seeds,
43};
44
45use super::r#enum::{
46    herbaceous_or_woody::HerbaceousOrWoody, life_cycle::LifeCycle,
47    light_requirement::LightRequirement, privacy_access_control::PrivacyAccessControl,
48    quality::Quality, quantity::Quantity, shade::Shade, soil_texture::SoilTextureEnum,
49    taxonomic_rank::TaxonomicRank, water_requirement::WaterRequirementEnum,
50};
51
52/// The `Plants` entity builds up an hierarchical structure, see `/doc/database/hierarchy.md`:
53///
54/// Use case for plant attributes is described in `/doc/usecases/assigned/plant_attributes.md`.
55///
56#[doc = include_str!("../../../doc/database/hierarchy.md")]
57///
58#[derive(Debug, Identifiable, Queryable, QueryableByName)]
59#[diesel(table_name = plants)]
60pub struct Plants {
61    /// *Used* at many places
62    /// - The internal id of the plant.
63    /// - *Database fill ratio:* 100.00%
64    pub id: i64,
65
66    /// *Used* at many places
67    /// - The unique name of the plant.
68    /// - The structure is described above (`doc/database/hierarchy.md`).
69    /// - *Database fill ratio:* 100.00%
70    /// - *Scraper fill ratio:* 100.00%
71    pub unique_name: String,
72
73    /// *Used* at many places
74    /// - The list of the common names of the plant in English.
75    /// - *Fetched from* `PracticalPlants` and Permapeople.
76    /// - *Database fill ratio:* 70.69%
77    /// - *Scraper fill ratio:* 71.34%
78    pub common_name_en: Option<Vec<Option<String>>>,
79
80    /// *Used* at many places
81    /// - The list of the common names of the plant in German.
82    /// - *Fetched from* Wikidata API if not present in any source datasets.
83    /// - *Database fill ratio:* 20.20%
84    /// - *Scraper fill ratio:* 20.37%
85    pub common_name_de: Option<Vec<Option<String>>>,
86
87    // /// - The edible use of the plant, answering: Which food type can be produced from this plant, e.g. oil?
88    // /// - Interesting for search functionality.
89    // /// - *Fetched from* Permapeople as `edible_uses` and merged with Reinsaat.
90    /// - *Not used*
91    /// - *Scraper fill ratio:* 5.12%
92    // pub edible_uses_en: Option<String>,
93
94    // /// - *Fetched from* PracticalPlants as `medicinal_uses` and merged with Permapeople.
95    /// - *Not used*
96    /// - *Scraper fill ratio:* 0.71%
97    //pub medicinal_uses: Option<String>,
98
99    // /// - Only for references.
100    // /// - *Fetched from* PracticalPlants)
101    /// - *Not used*
102    /// - *Scraper fill ratio:* 26.73%
103    // pub material_uses_and_functions: Option<String>,
104
105    // /// - Only for references.
106    // /// - *Fetched from* PracticalPlants)
107    /// - *Not used*
108    /// - *Scraper fill ratio:* 50.08%
109    // pub botanic: Option<String>,
110
111    // /// - Only informational.
112    // /// - *Fetched from* PracticalPlants
113    // /// - Plants are not only used for food but also for other uses, e.g. fiber to produce paper.
114    /// - *Not used*
115    /// - *Scraper fill ratio:* 0.57%
116    // pub material_uses: Option<String>,
117    //
118    /// - *Used* for search ranking (diversity) and to be displayed in plant attributes.
119    /// - ecological and environmental function of the plant, especially nitrogen fixer is relevant for `PermaplanT`.
120    /// - *Fetched from* `PracticalPlants`)
121    /// - *Database fill ratio:* 12.51%
122    /// - *Scraper fill ratio:* 12.46%
123    pub functions: Option<String>,
124
125    // /// - Use `hardiness_zone` instead.
126    // /// - indication of the heat range a plant endures.
127    // /// - *Fetched from* `PracticalPlants`.
128    /// - *Not used*
129    /// - *Scraper fill ratio:* 0.03%
130    // pub heat_zone: Option<i16>,
131    //
132    /// - Shade tolerance of the plant, to be used together with `light_requirement`.
133    /// - *Used* in shade layer.
134    /// - *For example* a plant that has "no shade", should get a warning if placed in a shade.
135    /// - No shade: full sun exposure
136    /// - Light shade: moderately shaded throughout the day
137    /// - Partial shade: about 3-6 hours of direct sunlight
138    /// - Permanent shade: less than 3 hours of direct sunlight
139    /// - Shade indicates the shade tolerance. Plants obviously grow better with better light conditions.
140    /// - Warnings should only show if a plant is moved into a too dark spot.
141    ///   No warning should be shown when moved into a lighter spot.
142    /// - *Fetched from* `PracticalPlants`.
143    /// - *Database fill ratio:* 58.42%
144    /// - *Scraper fill ratio:* 58.26%
145    pub shade: Option<Shade>,
146
147    // /// - Currently unused (maybe later used in pH layer).
148    // /// - *See* explanation in `/doc/architecture/context.md`
149    // /// - Soil PH can be tested by the user with simple means (e.g. litmus).
150    // /// - *Fetched from* `PracticalPlants` and Permapeople (merged between Permapeople and `PracticalPlants`).
151    /// - *Not used*
152    /// - *Scraper fill ratio:* 0.54%
153    // pub soil_ph: Option<Vec<Option<SoilPh>>>,
154    //
155    /// - *See* explanation in `/doc/architecture/context.md`
156    /// - *Used* in soil layer.
157    /// - *Fetched from* `PracticalPlants` and Permapeople (merged with `soil_type` of Permapeople).
158    /// - *Database fill ratio:* 77.81%
159    /// - *Scraper fill ratio:* 77.78%
160    pub soil_texture: Option<Vec<Option<SoilTextureEnum>>>,
161
162    // /// - *NOT used* in hydrology layer
163    // ///   as it has poor quality and no additional data compared to water_requirement
164    // /// - *Fetched from* PracticalPlants
165    // /// - wet = drowned, (often) flooded or in general very moist, e.g. swamp
166    // /// - moist = humid, can hold some water, e.g. flat bed with humus
167    // /// - well drained = dry, low capacity to hold water, e.g. sandhill.
168    /// - *Scraper fill ratio:* 29.83%
169    // pub soil_water_retention: Option<Vec<Option<SoilWaterRetention>>>,
170
171    // /// - Only informational.
172    // /// - *Fetched from* PracticalPlants
173    // /// - gives information about environmental conditions, such as drought or wind tolerance
174    /// - *Not used*
175    /// - *Scraper fill ratio:* 12.26%
176    //pub environmental_tolerances: Option<Vec<Option<String>>>,
177
178    // /// - *Fetched from* PracticalPlants
179    /// - *Not used*
180    /// - *Scraper fill ratio:* 0.18%
181    //pub native_geographical_range: Option<String>,
182
183    // /// - *Fetched from* `PracticalPlants`
184    /// - *Not used*
185    /// - *Scraper fill ratio:* 0.11%
186    //pub native_environment: Option<String>,
187
188    // /// - Interesting for search functionality.
189    // /// - *Fetched from* `PracticalPlants`
190    // /// - informs about the (vertical) layer, that the plant usually inhabits, e.g. soil surface or canopy
191    /// - *Not used*
192    /// - *Scraper fill ratio:* 12.70%
193    // pub ecosystem_niche: Option<String>,
194
195    // /// - Only informational.
196    // /// - deciduous = plants loose leaves in winter.
197    // /// - evergreen = Plants don't throw leaves (e.g. pine tree).
198    // /// - Not applicable for annual plants.
199    // /// - *Fetched from* `PracticalPlants` and merged with `leaves` of Permapeople.
200    /// - *Not used*
201    /// - *Scraper fill ratio:* 23.45%
202    // pub deciduous_or_evergreen: Option<DeciduousOrEvergreen>,
203
204    /// - *Used* Displayed in the plant attributes.
205    /// - Only informational.
206    /// - Fetched from `PracticalPlants`
207    /// - informs about the plant physiology
208    /// - woody = grows woody parts
209    /// - herbaceous = doesn't grow wood, shoots remain soft/green.
210    /// - *Database fill ratio:* 22.33%
211    /// - *Scraper fill ratio:* 22.47%
212    pub herbaceous_or_woody: Option<HerbaceousOrWoody>,
213
214    /// - *Used* in search and attribute
215    /// - Determines life span of the plant.
216    /// - *Fetched from* `PracticalPlants` and Permapeople (merged with `life_cycle` of Permapeople).
217    /// - *Database fill ratio:* 61.91%
218    /// - *Scraper fill ratio:* 61.75%
219    pub life_cycle: Option<Vec<Option<LifeCycle>>>,
220
221    // /// - Only informational.
222    // /// - *Fetched from* `PracticalPlants` and Permapeople (merged with `growth` of Permapeople).
223    /// - *Not used*
224    /// - *Scraper fill ratio:* 23.56%
225    // pub growth_rate: Option<Vec<Option<GrowthRate>>>,
226
227    /// - *Used only informational, is in rw attribute
228    /// - *Fetched from* `PracticalPlants` as `mature_size_height` and merged with Permapeople.
229    /// - informs about the maximum height that the plant gains in cm
230    /// - *Database fill ratio:* 71.95%
231    /// - *Scraper fill ratio:* 71.92%
232    pub height: Option<i32>,
233
234    // /// - Determines how large the plant can grow in diameter.
235    // /// - Other plants should get a warning if planted within this area.
236    // /// - *TODO:* replaced with spread, will keep this for now for information
237    // /// - *Fetched from* `PracticalPlants` as `mature_size_width` and merged with Permapeople.
238    /// - *Not used*
239    /// - *Scraper fill ratio:* 17.44%
240    //pub width: Option<String>,
241
242    // /// - Only informational.
243    // /// - *Fetched from* `PracticalPlants`
244    /// - *Not used*
245    /// - *Scraper fill ratio:* 14.32%
246    // pub fertility: Option<Vec<Option<Fertility>>>,
247
248    // /// - Only informational.
249    // /// - *Fetched from* PracticalPlants
250    /// - *Not used*
251    /// - *Scraper fill ratio:* 0.35%
252    //pub flower_colour: Option<String>,
253
254    // /// - Only informational.
255    // /// - *Fetched from* PracticalPlants
256    // /// - a plant can contain flowers of two different sexes, male or female (monoecious), a plant can contain only flowers of one specific sex and therefore needs at least another plant of the other sex to reproduce (dioecious) or can contain flowers that have both the sexes within the same flower (hermaphrodite).
257    /// - *Not used*
258    /// - *Scraper fill ratio:* 49.30%
259    // pub flower_type: Option<FlowerType>,
260
261    /// - Is readonly in attribute
262    /// - The creation date of the entry (actual time).
263    /// - Only for administration.
264    /// - *Database fill ratio:* 100.00%
265    /// - *Scraper fill ratio:* 70.78%
266    pub created_at: NaiveDateTime,
267
268    /// - Is readonly in attribute
269    /// - The last update date of the entry (actual time).
270    /// - Only for administration.
271    /// - *Database fill ratio:* 100.00%
272    /// - *Scraper fill ratio:* 70.78%
273    pub updated_at: NaiveDateTime,
274
275    /// - *Used* so that an icon can be shown in the search results. Also displayed in the plant attributes.
276    /// - Will be used in watering layer.
277    /// - Fetched from `PracticalPlants` and merged with `has_drought_tolerance` of Permapeople.
278    /// - *Database fill ratio:* 53.44%
279    /// - *Scraper fill ratio:* 53.27%
280    pub has_drought_tolerance: Option<bool>,
281
282    // /// - *Fetched from* `PracticalPlants`.
283    /// - *Not used*
284    /// - *Scraper fill ratio:* 7.46%
285    // pub tolerates_wind: Option<bool>,
286
287    // /// - The list of the references of the plant.
288    // /// - `references` items link to these items.
289    // /// - Only informational.
290    /// - *Not used*
291    /// - *Scraper fill ratio:* 45.96%
292    // pub plant_references: Option<Vec<Option<String>>>,
293
294    // /// - Boolean value indicating whether the plant is a tree.
295    // /// - Plants with `is_tree == true` can be used in the tree layer.
296    // /// - In plants layer all plants can be used.
297    // /// - *Initial value* is to `True` if  herbaceous_or_woody (woody) and life_cycle (perennial)
298    /// - *Not used*
299    /// - *Scraper fill ratio:* 0.08%
300    // pub is_tree: Option<bool>,
301
302    // /// - Only informational.
303    // /// - *Initial value* is to `light feeder` if "Nutritionally poor soil" in `environmental_tolerances` is present.
304    /// - *Not used*
305    /// - *Scraper fill ratio:* 0.03%
306    // pub nutrition_demand: Option<NutritionDemand>,
307
308    // /// - Number value between -1..6 (-1 should be printed as 00)
309    /// - *Not used*
310    // /// - *Fill ratio:* 0%
311    // pub preferable_permaculture_zone: Option<i16>,
312
313    // /// - When article was modified last time.
314    // /// - Only for administration.
315    // /// - Date value fetched from `PracticalPlants` page showing the last modification date of the plant.
316    /// - *Not used*
317    /// - *Scraper fill ratio:* 50.21%
318    // pub article_last_modified_at: Option<NaiveDateTime>,
319
320    /// - *Used* To diplay an icon in the search results.
321    /// - USDA Hardiness Zone (without subranges).
322    /// - Important information.
323    /// - Fetched from `PracticalPlants` and Permapeople (merged with `usda_hardiness_zone` of Permapeople).
324    /// - *Database fill ratio:* 58.25%
325    /// - *Scraper fill ratio:* 58.08%
326    pub hardiness_zone: Option<String>,
327
328    /// - Shade tolerance of the plant, to be used together with shade.
329    /// - *Used* in shade layer.
330    /// - *For example* a plant that has "Full sun", should get a warning if placed in a shade.
331    /// - **Fetched from*** `PracticalPlants` and Permapeople (merged with `sun` of `PracticalPlants`)
332    /// - Full sun: full sun exposure
333    /// - Partial sun/shade: about 3-6 hours of direct sunlight or moderately shaded throughout the day
334    /// - Full shade: less than 3 hours of direct sunlight or almost no sunlight/no direct sunlight
335    /// - *Database fill ratio:* 77.96%
336    /// - *Scraper fill ratio:* 77.93%
337    pub light_requirement: Option<Vec<Option<LightRequirement>>>,
338
339    /// - *Used* in hydrology layer.
340    /// - *Fetched from* `PracticalPlants` and Permapeople (merged with `water` of `PracticalPlants`).
341    /// - water = completely aquatic;
342    /// - wet = drowned, (often) flooded or in general very moist, e.g. swamp;
343    /// - moist = humid, regular water supply, e.g. flat bed with humus;
344    /// - well drained = dry, little water input.
345    /// - *Database fill ratio:* 77.93%
346    /// - *Scraper fill ratio:* 77.90%
347    pub water_requirement: Option<Vec<Option<WaterRequirementEnum>>>,
348
349    // /// - Only informational.
350    // /// - *Fetched from* Permapeople (renamed from `propagation`)
351    // /// - How to reproduce a plant: cuttings = cut pieces of wood; layering = let low branches reach the soil to root; Seed - direct sow = sow directly the seeds; division = split the rhizomes (roots) into pieces; Spores = plant reproduces via spores (e.g. ferns, funghi); seed - transplant = raise indoors from seed and transplant to outdoors later
352    /// - *Not used*
353    /// - *Scraper fill ratio:* 0.73%
354    // pub propagation_method: Option<Vec<Option<PropagationMethod>>>,
355
356    // /// - Only informational.
357    // /// - May be used in search functionality (low priority).
358    // /// - *Fetched from* Permapeople.
359    /// - *Not used*
360    /// - *Scraper fill ratio:* 27.55%
361    // pub alternate_name: Option<String>,
362
363    // /// - Only informational.
364    // /// - *Fetched from* Permapeople.
365    /// - *Not used*
366    /// - *Scraper fill ratio:* 0.02%
367    //pub diseases: Option<String>,
368
369    /// - *Used* so that an icon can be shown in the search results. Also displayed in the plant attributes.
370    /// - Important information.
371    /// - *Fetched from* Permapeople.
372    /// - *Database fill ratio:* 55.02%
373    /// - *Scraper fill ratio:* 54.98%
374    pub edible: Option<bool>,
375
376    /// - Only informational.
377    /// - *Used* Displayed in the plant attributes.
378    /// - *Fetched from* Permapeople.
379    /// - which organ of the plant can be eaten, e.g. root, leaves.
380    /// - *Database fill ratio:* 56.76%
381    /// - *Scraper fill ratio:* 56.56%
382    pub edible_parts: Option<Vec<Option<String>>>,
383
384    // /// - Only informational.
385    // /// - *Fetched from* Permapeople.
386    // /// - Reinsaat: `Keimtemperatur` should be copied to `germination_temperature`
387    // /// - Germination means that all conditions are right for a seed to start growing. Temperature is one essential factor.
388    /// - *Not used*
389    /// - *Scraper fill ratio:* 1.60%
390    //pub germination_temperature: Option<String>,
391
392    // /// - *Fetched from* Permapeople.
393    /// - *Not used*
394    /// - *Scraper fill ratio:* 29.12%
395    //pub introduced_into: Option<String>,
396
397    // /// - Only informational.
398    // /// - *Fetched from* Permapeople as \`layer\` and renamed.
399    // /// - Habitus describes the shape of a plant.
400    /// - *Not used*
401    /// - *Scraper fill ratio:* 37.94%
402    //pub habitus: Option<String>,
403
404    // /// - *Fetched from* Permapeople.
405    /// - *Not used*
406    /// - *Scraper fill ratio:* 0.07%
407    //pub medicinal_parts: Option<String>,
408
409    // /// - Only informational.
410    // /// - *Fetched from* Permapeople.
411    /// - *Not used*
412    /// - *Scraper fill ratio:* 63.83%
413    //pub native_to: Option<String>,
414
415    // /// - *Fetched from* Permapeople.
416    /// - *Not used*
417    /// - *Scraper fill ratio:* 68.35%
418    //pub plants_for_a_future: Option<String>,
419
420    // /// - *Fetched from* Permapeople.
421    /// - *Not used*
422    /// - *Scraper fill ratio:* 65.01%
423    //pub plants_of_the_world_online_link: Option<String>,
424
425    // /// - *Fetched from* Permapeople.
426    /// - *Not used*
427    /// - *Scraper fill ratio:* 11.44%
428    //pub plants_of_the_world_online_link_synonym: Option<String>,
429
430    // /// - Only informational.
431    // /// - *Fetched from* PracticalPlants as `pollinators` and merged with `pollination` of Permapeople.
432    // /// - Pollination is the process that the pollen (male part) gets united with the pistil (female part), e.g. via bees, wind.
433    /// - *Not used*
434    /// - *Scraper fill ratio:* 38.03%
435    //pub pollination: Option<String>,
436
437    // /// - Only informational.
438    // /// - *Fetched from* Permapeople.
439    /// - *Not used*
440    /// - *Scraper fill ratio:* 0.11%
441    //pub propagation_transplanting_en: Option<String>,
442
443    // /// - Nearly empty.
444    // /// - *Fetched from* Permapeople.
445    /// - *Not used*
446    /// - *Scraper fill ratio:* 0.01%
447    //pub resistance: Option<String>,
448
449    // /// - Only informational.
450    // /// - *Fetched from* Permapeople.
451    // /// - Root type describes the shape of the roots.
452    /// - *Not used*
453    /// - *Scraper fill ratio:* 0.19%
454    //pub root_type: Option<String>,
455
456    // /// - Only informational.
457    // /// - *Fetched from* Permapeople as `seed_planting_depth` and renamed.
458    // /// - Reinsaat: `Sowing depth` should be copied to `seed_planting_depth_en`
459    // /// - When sowing each plant has a specific value how deep the seeds should be covered with soil.
460    /// - *Not used*
461    /// - *Scraper fill ratio:* 0.06%
462    //pub seed_planting_depth_en: Option<String>,
463
464    // /// - Only informational.
465    // /// - *Fetched from* Permapeople.
466    // /// - expected average life span (in years) of a seed of a certain specie.
467    /// - *Not used*
468    /// - *Scraper fill ratio:* 0.51%
469    //pub seed_viability: Option<String>,
470
471    // /// - The final part of the URL of the plant on the Permapeople website.
472    // /// - This field can be potentially used to construct the `external_url` field traversing through all the parents given by `parent_id`.
473    // /// - *Fetched from* Permapeople.
474    /// - *Not used*
475    /// - *Scraper fill ratio:* 70.78%
476    //pub slug: Option<String>,
477
478    /// - **Used**
479    /// - How far a plant spreads (The 'width' of a plant) in cm
480    /// - *Fetched from* Permapeople.
481    /// - *Database fill ratio:* 78.38%
482    /// - *Scraper fill ratio:* 78.36%
483    pub spread: Option<i32>,
484
485    // /// - *Fetched from* Permapeople.
486    /// - *Not used*
487    /// - *Scraper fill ratio:* 1.69%
488    //pub utility: Option<String>,
489
490    /// - *Used* so that an icon can be shown in the search results. Also displayed in the plant attributes.
491    /// - Important information.
492    /// - *Fetched from* Permapeople.
493    /// - specific warnings for eather human, animal or environmental well-being, e.g. toxic, invasive.
494    /// - *Database fill ratio:* 8.77%
495    /// - *Scraper fill ratio:* 8.69%
496    pub warning: Option<String>,
497
498    // /// - *Fetched from* Permapeople.
499    /// - *Not used*
500    /// - *Scraper fill ratio:* 0.05%
501    //pub when_to_plant_cuttings_en: Option<String>,
502
503    // /// - *Fetched from* Permapeople.
504    /// - *Not used*
505    /// - *Scraper fill ratio:* 0.06%
506    //pub when_to_plant_division_en: Option<String>,
507
508    // /// - *Fetched from* Permapeople.
509    /// - *Not used*
510    /// - *Scraper fill ratio:* 0.15%
511    //pub when_to_plant_transplant_en: Option<String>,
512
513    // /// - Only informational.
514    // /// - *Fetched from* Permapeople.
515    /// - *Not used*
516    /// - *Scraper fill ratio:* 0.18%
517    //pub when_to_sow_indoors_en: Option<String>,
518
519    // /// - Only informational.
520    // /// - *Fetched from* Permapeople as `when_to_sow_outdoors` and renamed.
521    // /// - Reinsaat: `Sowing` or `Direct Sowing` or `Sowing outdoors` or `Sowing Direct Outdoors` should be copied to `sowing_outdoors_en`
522    /// - *Not used*
523    /// - *Scraper fill ratio:* 0.27%
524    //pub sowing_outdoors_en: Option<String>,
525
526    // /// - Only informational.
527    // /// - *Fetched from* Permapeople.
528    /// - *Not used*
529    /// - *Scraper fill ratio:* 0.44%
530    //pub when_to_start_indoors_weeks: Option<String>,
531
532    // /// - Only informational.
533    // /// - *Fetched from* Permapeople.
534    /// - *Not used*
535    /// - *Scraper fill ratio:* 0.09%
536    //pub when_to_start_outdoors_weeks: Option<String>,
537
538    // /// - Only informational.
539    // /// - *Fetched from* Permapeople.
540    // /// - Stratification is the process that a seed must go through to get triggered for germination, e.g. by a certain threshold of minus degrees.
541    /// - *Not used*
542    /// - *Scraper fill ratio:* 0.02%
543    //pub cold_stratification_temperature: Option<String>,
544
545    // /// - Only informational.
546    // /// - *Fetched from* Permapeople.
547    // /// - Suggested change
548    // /// - *Fetched from* Permapeople.
549    // /// - Stratification is the process that a seed must go through to get triggered for germination, e.g. by a certain amount of time under cold temperatures.
550    /// - *Not used*
551    /// - *Scraper fill ratio:* 0.04%
552    //pub cold_stratification_time: Option<String>,
553
554    // /// - Only informational.
555    // /// - *Fetched from* Permapeople.
556    // /// - Reinsaat: `1st harvest` should be copied to `days_to_harvest`
557    /// - *Not used*
558    /// - *Scraper fill ratio:* 0.73%
559    //pub days_to_harvest: Option<String>,
560
561    // /// - Needed for occupied space and in attributes
562    // /// - *TODO:* should be number and then be used for calender
563    //pub life_cycle_days: Option<int>,
564
565    // /// - *Fetched from* Permapeople.
566    /// - *Not used*
567    /// - *Scraper fill ratio:* 0.15%
568    //pub habitat: Option<String>,
569
570    // /// - One number means it is spacing between plants and rows. Two numbers means first is spacing between plants, second between rows.
571    // /// - Only informational.
572    // /// - *Fetched from* Permapeople as `spacing` and from Reinsaat as `Distances` and renamed.
573    // /// - Reinsaat: `Distances` or `Spacing` should be copied to `spacing_en`
574    /// - *Not used*
575    /// - *Scraper fill ratio:* 0.53%
576    //pub spacing_en: Option<String>,
577
578    // /// - *Fetched from* Permapeople as `wikipedia` and renamed.
579    /// - *Not used*
580    /// - *Scraper fill ratio:* 37.12%
581    //pub wikipedia_url: Option<String>,
582
583    // /// - Only informational.
584    // /// - *Fetched from* Permapeople.
585    /// - *Not used*
586    /// - *Scraper fill ratio:* 0.20%
587    //pub days_to_maturity: Option<String>,
588
589    // /// - Nearly empty.
590    // /// - *Fetched from* Permapeople.
591    /// - *Not used*
592    /// - *Scraper fill ratio:* 0.02%
593    //pub pests: Option<String>,
594
595    /// - Only for administration.
596    /// - The version of the entry.
597    /// - To be incremented after every relevant change.
598    /// - *Fetched from* Permapeople.
599    /// - *Database fill ratio:* 70.11%
600    /// - *Scraper fill ratio:* 70.78%
601    pub version: Option<i16>,
602
603    // /// - Only informational.
604    // /// - *Fetched from* Permapeople.
605    // /// - Germination time describes the time (days, weeks, months) that a seed needs to germinate given the right conditions.
606    /// - *Not used*
607    /// - *Scraper fill ratio:* 0.41%
608    //pub germination_time: Option<String>,
609
610    // /// - The description of the entry.
611    // /// - *Fetched from* Permapeople.
612    /// - *Not used*
613    /// - *Scraper fill ratio:* 3.73%
614    //pub description: Option<String>,
615
616    // /// - TODO: (not yet in database) add to attributes
617    // /// - Short important information to shown.
618    //pub info: Option<String>,
619
620    // /// - *Fetched from* permapeople id of the parent entry pointing to the `external_id` column.
621    /// - *Not used*
622    /// - *Scraper fill ratio:* 1.54%
623    //pub parent_id: Option<String>,
624
625    // /// - Enum value indicating the source of the entry.
626    /// - *Not used*
627    /// - *Scraper fill ratio:* 79.18%
628    // pub external_source: Option<ExternalSource>,
629
630    // /// - The external id of the entry used in combination with the `external_source` column.
631    /// - *Not used*
632    /// - *Scraper fill ratio:* 70.78%
633    //pub external_id: Option<String>,
634
635    // /// - The external URL provided by the origin source.
636    /// - *Not used*
637    /// - *Scraper fill ratio:* 7.55%
638    //pub external_url: Option<String>,
639
640    // /// - Only informational.
641    // /// - *Fetched from* PracticalPlants as `root_zone_tendency` and merged with root_depth of Permapeople.
642    // /// - Root depth can be considered when planning polycultures, e.g. combining shallow roots with deep roots.
643    /// - *Not used*
644    /// - *Scraper fill ratio:* 0.14%
645    //pub root_depth: Option<String>,
646
647    // /// - The article number `Artikelnummer` of the plant in the Reinsaat database.
648    /// - *Not used*
649    /// - *Scraper fill ratio:* 6.05%
650    //pub external_article_number: Option<String>,
651
652    // /// - `Portionsinhalt` should be called `external_portion_content`
653    // /// - *Fetched from* Reinsaat.
654    /// - *Not used*
655    /// - *Scraper fill ratio:* 5.67%
656    //pub external_portion_content: Option<String>,
657
658    // /// - Only informational.
659    // /// - *Fetched from* Reinsaat as \`Direktsaat\` and renamed.
660    // /// - `Direktsaat` or `Aussaat` should be called `sowing_outdoors_de`
661    /// - *Not used*
662    /// - *Scraper fill ratio:* 0.82%
663    //pub sowing_outdoors_de: Option<String>,
664
665    /// - *Used* Displayed in the plant attributes.
666    /// - String array of numbers representing a time period.
667    /// - The year is divided into 24 periods of half a month each.
668    /// - *For example* "\[8,9,10\]" means from the 2nd half of April to the 2nd half of May incl.
669    /// - *Fetched from* Reinsaat
670    /// - `Aussaat/ Pflanzung Freiland` should be called `sowing_outdoors`
671    /// - *Database fill ratio:* 5.73%
672    /// - *Scraper fill ratio:* 5.64%
673    pub sowing_outdoors: Option<Vec<Option<i16>>>,
674
675    /// - *Used* Displayed in the plant attributes.
676    /// - String array of numbers representing a time period.
677    /// - The year is divided into 24 periods of half a month each.
678    /// - *For example* "\[8,9,10\]" means from the 2nd half of April to the 2nd half of May incl.
679    /// - `Ernte` should be called `harvest_time`
680    /// - *Fetched from* Reinsaat
681    /// - *Database fill ratio:* 5.58%
682    /// - *Scraper fill ratio:* 4.97%
683    pub harvest_time: Option<Vec<Option<i16>>>,
684
685    /*
686    /// - Only informational.
687    /// - *Fetched from* Reinsaat.
688    /// - `Abstände` should be called `spacing_de`
689    /// - *Not used*
690    /// - *Scraper fill ratio:* 2.37%
691    //pub spacing_de: Option<String>,
692
693    /// - Only informational.
694    /// - *Fetched from* Reinsaat.
695    /// - *Not used*
696    /// - `Saatgutbedarf` should be called `required_quantity_of_seeds_de`
697    /// - *Scraper fill ratio:* 1.29%
698    //pub required_quantity_of_seeds_de: Option<String>,
699
700    /// - Only informational.
701    /// - *Fetched from* Reinsaat.
702    /// - `Required quantity of seeds` should be called `required_quantity_of_seeds_en`
703    /// - *Not used*
704    /// - *Scraper fill ratio:* 2.77%
705    //pub required_quantity_of_seeds_en: Option<String>,
706
707    /// - Only informational.
708    /// - *Fetched from* Reinsaat.
709    /// - `Saattiefe` should be called `seed_planting_depth_de`
710    /// - When sowing, each plant has a specific value how deep the seeds should be covered with soil.
711    /// - *Not used*
712    /// - *Scraper fill ratio:* 2.22%
713    //pub seed_planting_depth_de: Option<String>,
714
715    /// - German version of thousand grain weight (German: Tausendkornmasse)
716    /// - Only informational.
717    /// - *Fetched from* Reinsaat.
718    /// - Called `Tausendkornmasse` in Reinsaat
719    /// - *Not used*
720    /// - *Scraper fill ratio:* 2.12%
721    //pub seed_weight_1000_de: Option<String>,
722
723    /// - English version of thousand grain weight (German: Tausendkornmasse)
724    /// - Only informational.
725    /// - *Fetched from* Reinsaat.
726    /// - Called `Thousand seeds mass` in Reinsaat
727    /// - *Not used*
728    /// - *Scraper fill ratio:* 2.17%
729    //pub seed_weight_1000_en: Option<String>,
730
731    /// - Number for thousand grain weight (German: Tausendkornmasse)
732    /// - used in `doc/usecases/buy_seeds.md` to calculate seed weight based on number of plants.
733    /// - *Fetched from* Permapeople as `1000_seed_weight_g` and renamed.
734    /// - *TODO:* merge with data from reinsaat: `Tausendkorngewicht (TKG)` should be copied to `seed_weight` (remove ` g`)
735    /// - *Not used*
736    /// - *Scraper fill ratio:* 2.90%
737    // pub seed_weight_1000: Option<f64>,
738
739    /// - Only informational.
740    /// - *Fetched from* Reinsaat.
741    /// - `Suitable for professional cultivation` should be called `machine_cultivation_possible`
742    /// - *Not used*
743    /// - *Scraper fill ratio:* 7.55%
744    //pub machine_cultivation_possible: Option<bool>,
745
746    /// - *Fetched from* Reinsaat.
747    /// - could be used for plant search and informational.
748    /// - `subcategory` from Reinsaat should be copied to `edible_uses_de` and `edible_uses_en` respectively (DE and EN version)
749    /// - *Not used*
750    /// - *Scraper fill ratio:* 5.10%
751    //pub edible_uses_de: Option<String>,
752    */
753    /// - Hierarchy fields
754    /// - Either *Fetched from* `PracticalPlants` and Permapeople
755    /// - Or determined from the unique name
756    /// - Or set by scraper overrides
757    /// - *Database fill ratio:* 100.00%
758    /// - *Scraper fill ratio:* 100.00%
759    pub rank: TaxonomicRank,
760    pub family: Option<i64>,
761    pub genus: Option<i64>,
762    pub species: Option<i64>,
763    pub variety: Option<i64>,
764
765    /// - The path to the icon of the plant.
766    /// - *Database fill ratio:* 2.32%
767    /// - *Scraper fill ratio:* 2.12%
768    pub icon_path: Option<String>,
769}
770
771/// The `PlantsAndFamily` entity used for a self join.
772#[derive(Queryable)]
773pub struct PlantsAndFamily {
774    /// The plants entity
775    pub plant: Plants,
776    /// The plants family name
777    pub family_name: Option<String>,
778}
779/// The `Seed` entity.
780#[derive(Identifiable, Queryable)]
781#[diesel(table_name = seeds)]
782pub struct Seed {
783    /// The record id of the seed.
784    pub id: i64,
785    /// An additional name for the seed.
786    pub name: String,
787    /// When the seeds were harvested.
788    pub harvest_year: i16,
789    /// When the seeds should be used by.
790    pub use_by: Option<NaiveDate>,
791    /// Where the seeds came from.
792    pub origin: Option<String>,
793    /// What the seeds taste like.
794    pub taste: Option<String>,
795    /// The yield of the seeds.
796    pub yield_: Option<String>,
797    /// How many seeds there are.
798    pub quantity: Quantity,
799    /// The quality of the seeds.
800    pub quality: Option<Quality>,
801    /// How much the seeds cost.
802    pub price: Option<i16>,
803    /// How many generations the seeds have been grown.
804    pub generation: Option<i16>,
805    /// Notes about the seeds.
806    pub notes: Option<String>,
807    /// The id of the plant this seed belongs to.
808    pub plant_id: i64,
809    /// The id of the creator of the seed.
810    pub created_by: Uuid,
811    /// Timestamp indicating when the seed was archived.
812    /// Empty if the seed was not archived.
813    pub archived_at: Option<NaiveDateTime>,
814}
815
816/// The `NewSeed` entity.
817#[allow(clippy::missing_docs_in_private_items)] // TODO: See #97.
818#[derive(Insertable)]
819#[diesel(table_name = seeds)]
820pub struct NewSeed {
821    pub name: String,
822    pub plant_id: i64,
823    pub harvest_year: i16,
824    pub use_by: Option<NaiveDate>,
825    pub origin: Option<String>,
826    pub taste: Option<String>,
827    pub yield_: Option<String>,
828    pub quantity: Quantity,
829    pub quality: Option<Quality>,
830    pub price: Option<i16>,
831    pub generation: Option<i16>,
832    pub notes: Option<String>,
833    pub created_by: Uuid,
834}
835
836/// The `Map` entity.
837#[derive(Identifiable, Queryable)]
838#[diesel(table_name = maps)]
839pub struct Map {
840    /// The id of the map.
841    pub id: i64,
842    /// The name of the map.
843    pub name: String,
844    /// The date the map is supposed to be deleted.
845    pub deletion_date: Option<NaiveDate>,
846    /// The date the last time the map view was opened by any user.
847    pub last_visit: Option<NaiveDate>,
848    /// A flag indicating if this map is marked for deletion.
849    pub is_inactive: bool,
850    /// The zoom factor of the map.
851    pub zoom_factor: i16,
852    /// An enum indicating if this map is private or not.
853    pub privacy: PrivacyAccessControl,
854    /// The description of the map.
855    pub description: Option<String>,
856    /// The location of the map as a latitude/longitude point.
857    pub location: Option<Point>,
858    /// The id of the creator of the map.
859    pub created_by: Uuid,
860    /// The geometry of the map.
861    pub geometry: Polygon<Point>,
862    /// When the map was created.
863    pub created_at: NaiveDateTime,
864    /// When a map was last modified, e.g., by modifying plantings.
865    pub modified_at: NaiveDateTime,
866    /// By whom the map was last modified.
867    pub modified_by: Uuid,
868}
869
870/// The `NewMap` entity.
871#[derive(Insertable)]
872#[diesel(table_name = maps)]
873pub struct NewMap {
874    /// The name of the map.
875    pub name: String,
876    /// For a new map the same as `created_by`.
877    pub deletion_date: Option<NaiveDate>,
878    /// The date the last time the map view was opened by any user.
879    pub last_visit: Option<NaiveDate>,
880    /// A flag indicating if this map is marked for deletion.
881    pub is_inactive: bool,
882    /// The zoom factor of the map.
883    pub zoom_factor: i16,
884    /// An enum indicating if this map is private or not.
885    pub privacy: PrivacyAccessControl,
886    /// The description of the map.
887    pub description: Option<String>,
888    /// The location of the map as a latitude/longitude point.
889    pub location: Option<Point>,
890    /// The id of the creator of the map.
891    pub created_by: Uuid,
892    /// The geometry of the map.
893    pub geometry: Polygon<Point>,
894    /// The user who last modified the planting.
895    pub modified_by: Uuid,
896}
897
898/// The `UpdateMap` entity.
899#[derive(AsChangeset)]
900#[diesel(table_name = maps)]
901pub struct UpdateMap {
902    /// The name of the map.
903    pub name: Option<String>,
904    /// An enum indicating if this map is private or not.
905    pub privacy: Option<PrivacyAccessControl>,
906    /// The description of the map.
907    pub description: Option<String>,
908    /// The location of the map as a latitude/longitude point.
909    pub location: Option<Point>,
910}
911
912/// The `UpdateMapGeometry` entity.
913#[derive(AsChangeset)]
914#[diesel(table_name = maps)]
915pub struct UpdateMapGeometry {
916    /// New Map Bounds
917    pub geometry: Polygon<Point>,
918}
919
920/// The `GuidedTourProgress` entity.
921#[derive(Identifiable, Queryable)]
922#[diesel(primary_key(user_id, step_key), table_name = guided_tour_progress)]
923pub struct GuidedTourProgress {
924    /// ID of the user who completed the tour step
925    pub user_id: Uuid,
926    /// Human readable id of the step the user completed
927    pub step_key: String,
928    /// Time of completion
929    pub completed_at: NaiveDateTime,
930}
931
932/// Insertable for `guided_tour_progress` (`completed_at` uses DB default).
933#[derive(Insertable)]
934#[diesel(table_name = guided_tour_progress)]
935pub struct NewGuidedTourProgress {
936    /// ID of the user who is completing the step
937    pub user_id: Uuid,
938    /// Human readable id of the step the user is completing
939    pub step_key: String,
940}
941
942/// The `GuidedTourState` entity.
943#[derive(Insertable, Identifiable, Queryable)]
944#[diesel(primary_key(user_id), table_name = guided_tour_states)]
945pub struct GuidedTourState {
946    /// ID of the user
947    pub user_id: Uuid,
948    /// When the tour was paused
949    pub paused_at: Option<NaiveDateTime>,
950    /// How often the user has paused the tour already
951    pub pause_count: i32,
952}
953
954/// The `ApplicationSetting` entity.
955#[derive(Identifiable, Queryable)]
956#[diesel(primary_key(id), table_name = application_settings)]
957pub struct ApplicationSetting {
958    /// The id of the setting
959    pub id: i32,
960    /// The unique key of the setting
961    pub key: String,
962    /// The value of the setting
963    pub value: String,
964}
965
966/// The [`MapCollaborator`] entity.
967#[derive(Insertable, Identifiable, Queryable)]
968#[diesel(primary_key(map_id, user_id), table_name = map_collaborators)]
969pub struct MapCollaborator {
970    pub map_id: i64,
971    pub user_id: Uuid,
972    pub created_at: NaiveDateTime,
973}