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