Browse Source

Added inbuild database

integrate_codes_to_fields
anghenfil 2 years ago
parent
commit
c975e96748
  1. 3
      .idea/DigiPoll.iml
  2. 10
      .idea/misc.xml
  3. 693
      .idea/workspace.xml
  4. 8
      Cargo.toml
  5. 14
      README.md
  6. 54
      src/database/database.rs
  7. 2
      src/database/mod.rs
  8. 4
      src/database/tests.rs
  9. 74
      src/db_system/document.rs
  10. 2
      src/db_system/mod.rs
  11. 70
      src/db_system/storage.rs
  12. 5
      src/main.rs

3
.idea/DigiPoll.iml

@ -7,6 +7,9 @@
<sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/benches" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/../DigiPoll\examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../DigiPoll\tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/../DigiPoll\benches" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />

10
.idea/misc.xml

@ -1,16 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CargoProjects">
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="MacroExpansionManager">
<option name="directoryName" value="OzlyIuyN" />
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
<option name="version" value="2" />
</component>
</project>

693
.idea/workspace.xml

@ -8,14 +8,26 @@
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="CargoProjects">
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="ChangeListManager">
<list default="true" id="77587fc1-3757-4042-86e1-b4a4e81ff6db" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/database/tests.rs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/db_system/document.rs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/db_system/mod.rs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/db_system/storage.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/DigiPoll.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/DigiPoll.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-0.html" beforeDir="false" afterPath="$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-0.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-1.html" beforeDir="false" afterPath="$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-1.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data/polls/poll-1/result.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/polls/poll-1/result.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/webserver/delivery.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/webserver/delivery.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/webserver/templates.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/webserver/templates.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/database/database.rs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/database/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/database/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -26,37 +38,6 @@
<component name="DefaultGradleProjectSettings">
<option name="isMigrated" value="true" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/webserver/delivery.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="452">
<caret line="35" column="59" selection-start-line="35" selection-start-column="59" selection-end-line="35" selection-end-column="59" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/webserver/templates.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="19" column="67" lean-forward="true" selection-start-line="19" selection-start-column="67" selection-end-line="19" selection-end-column="67" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/webserver/site_poll_get.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="986">
<caret line="58" column="29" selection-start-line="58" selection-start-column="29" selection-end-line="58" selection-end-column="29" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
@ -69,7 +50,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>pr</find>
<find>/q</find>
<find>complete</find>
<find>Digip</find>
@ -99,113 +79,20 @@
<find>if(comp</find>
<find>session</find>
<find>result</find>
<find>CACHE.</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/webserver/Cargo.toml" />
<option value="$PROJECT_DIR$/src/webserver/src/lib.rs" />
<option value="$PROJECT_DIR$/src/webserver/src/lib/delivery.rs" />
<option value="$PROJECT_DIR$/src/webserver/src/lib/sites.rs" />
<option value="$PROJECT_DIR$/src/webserver/src/lib/mod.rs" />
<option value="$PROJECT_DIR$/src/filecache/mod.rs" />
<option value="$PROJECT_DIR$/src/filecache/cached_file.rs" />
<option value="$PROJECT_DIR$/data/polls/poll-1/pollinfo" />
<option value="$PROJECT_DIR$/data/polls/poll-1/questionblocks/block-1/blockinfo" />
<option value="$PROJECT_DIR$/data/polls/poll-1/questionblocks/block-1/question-1" />
<option value="$PROJECT_DIR$/src/utils.rs" />
<option value="$PROJECT_DIR$/data/polls/poll-1/questionblocks/block-1/block-1.html" />
<option value="$PROJECT_DIR$/src/utils/filesystem.rs" />
<option value="$PROJECT_DIR$/src/utils/mod.rs" />
<option value="$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-0/q2.html" />
<option value="$PROJECT_DIR$/src/filecache/cache.rs" />
<option value="$PROJECT_DIR$/src/webserver/formdata.rs" />
<option value="$PROJECT_DIR$/style/dashboard.css" />
<option value="$PROJECT_DIR$/src/database/code_management.rs" />
<option value="$PROJECT_DIR$/data/polls/poll-1/result.csv" />
<option value="$PROJECT_DIR$/Rocket.toml" />
<option value="$PROJECT_DIR$/style/global.css" />
<option value="$PROJECT_DIR$/src/webserver/images.rs" />
<option value="$PROJECT_DIR$/src/main.rs" />
<option value="$PROJECT_DIR$/src/database/mod.rs" />
<option value="$PROJECT_DIR$/style/poll.js" />
<option value="$PROJECT_DIR$/src/webserver/styles.rs" />
<option value="$PROJECT_DIR$/style/poll.css" />
<option value="$PROJECT_DIR$/src/utils/poll_generator.rs" />
<option value="$PROJECT_DIR$/src/webserver/session_manager.rs" />
<option value="$PROJECT_DIR$/data/polls/poll-1/poll.json" />
<option value="$PROJECT_DIR$/database-planning.txt" />
<option value="$PROJECT_DIR$/src/database/database.rs" />
<option value="$PROJECT_DIR$/src/webserver/sites.rs" />
<option value="$PROJECT_DIR$/src/webserver/site_poll_get.rs" />
<option value="$PROJECT_DIR$/src/webserver/site_index.rs" />
<option value="$PROJECT_DIR$/src/webserver/mod.rs" />
<option value="$PROJECT_DIR$/src/webserver/site_poll_post.rs" />
<option value="$PROJECT_DIR$/src/filecache/cache_error.rs" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/Cargo.toml" />
<option value="$PROJECT_DIR$/src/webserver/favicons.rs" />
<option value="$PROJECT_DIR$/src/webserver/favicon.rs" />
<option value="$PROJECT_DIR$/src/webserver/templates.rs" />
<option value="$PROJECT_DIR$/src/webserver/delivery.rs" />
</list>
</option>
<component name="MacroExpansionManager">
<option name="directoryName" value="OzlyIuyN" />
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="width" value="842" />
<option name="height" value="768" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="DigiPoll" type="b2602c69:ProjectViewProjectNode" />
<item name="DigiPoll" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="DigiPoll" type="b2602c69:ProjectViewProjectNode" />
<item name="DigiPoll" type="462c0819:PsiDirectoryNode" />
<item name="data" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="DigiPoll" type="b2602c69:ProjectViewProjectNode" />
<item name="DigiPoll" type="462c0819:PsiDirectoryNode" />
<item name="data" type="462c0819:PsiDirectoryNode" />
<item name="favicon" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="DigiPoll" type="b2602c69:ProjectViewProjectNode" />
<item name="DigiPoll" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="DigiPoll" type="b2602c69:ProjectViewProjectNode" />
<item name="DigiPoll" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="webserver" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="DigiPoll" type="b2602c69:ProjectViewProjectNode" />
<item name="DigiPoll" type="462c0819:PsiDirectoryNode" />
<item name="style" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="ProjectId" id="1PynSxeTSOmYSO9oejxoxT36GAD" />
<component name="PropertiesComponent">
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
@ -221,6 +108,7 @@
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="org.rust.cargo.project.model.PROJECT_DISCOVERY" value="true" />
<property name="org.rust.hideDetachedFileNotificationsC:/Users/anghenfil/IdeaProjects/DigiPoll/src/webserver/delivery.rs" value="true" />
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
@ -252,27 +140,82 @@
</list>
</option>
</component>
<component name="RunManager" selected="Cargo Command.Run">
<component name="RunManager" selected="Cargo Command.Test">
<configuration name="Run" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="channel" value="DEFAULT" />
<option name="command" value="run" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="true" />
<option name="emulateTerminal" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test db_system::document::test_document" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="channel" value="DEFAULT" />
<option name="command" value="test --package Surveyz --bin Surveyz db_system::document::test_document -- --exact" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="emulateTerminal" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test db_system::storage::testsave" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="channel" value="DEFAULT" />
<option name="command" value="test --package Surveyz --bin Surveyz db_system::storage::testsave -- --exact" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="emulateTerminal" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<method v="2" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="channel" value="DEFAULT" />
<option name="command" value="test -- --nocapture" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="emulateTerminal" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="build" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="channel" value="DEFAULT" />
<option name="command" value="build --all" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="emulateTerminal" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<method v="2" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Cargo Command.Test db_system::document::test_document" />
<item itemvalue="Cargo Command.Test db_system::storage::testsave" />
</list>
</recent_temporary>
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
<option name="version" value="2" />
</component>
<component name="SvnConfiguration">
<configuration />
@ -314,7 +257,20 @@
<workItem from="1551654833472" duration="217000" />
<workItem from="1555868101111" duration="704000" />
<workItem from="1555868845710" duration="10668000" />
<workItem from="1558381713856" duration="3243000" />
<workItem from="1558381713856" duration="4197000" />
<workItem from="1558622760888" duration="674000" />
<workItem from="1559076213976" duration="3572000" />
<workItem from="1559174871406" duration="56000" />
<workItem from="1559586100143" duration="4300000" />
<workItem from="1559676107073" duration="584000" />
<workItem from="1559776612127" duration="6654000" />
<workItem from="1560163484164" duration="12504000" />
<workItem from="1560202823819" duration="373000" />
<workItem from="1560205456342" duration="2826000" />
<workItem from="1560335283560" duration="715000" />
<workItem from="1560375791749" duration="591000" />
<workItem from="1566855221475" duration="1243000" />
<workItem from="1566856500934" duration="5818000" />
</task>
<task id="LOCAL-00001" summary="New project structure">
<created>1547901316778</created>
@ -351,12 +307,23 @@
<option name="project" value="LOCAL" />
<updated>1555885183531</updated>
</task>
<option name="localTasksCounter" value="6" />
<task id="LOCAL-00006" summary="Added favicon support and default favicon">
<created>1558385391295</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1558385391295</updated>
</task>
<task id="LOCAL-00007" summary="Bugfix: Added missing script closing tag (&lt;/script&gt;), smaller changes.">
<created>1559078712675</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1559078712675</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="213684000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
@ -366,79 +333,22 @@
<is-autoscroll-to-source value="true" />
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="-8" y="32" width="1936" height="1056" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.15991472" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Capture Tool" order="5" />
<window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.328594" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.4968017" visible="true" weight="0.30769232" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39968404" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.328594" />
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Terminal" order="8" sideWeight="0.49848944" weight="0.3280757" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50319827" side_tool="true" weight="0.30769232" />
<window_info anchor="bottom" id="Version Control" order="10" />
<window_info active="true" anchor="bottom" id="Messages" order="11" visible="true" weight="0.328594" />
<window_info anchor="bottom" id="Docker" order="12" show_stripe_button="false" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Capture Analysis" order="4" />
<window_info anchor="right" id="Theme Preview" order="5" />
<window_info anchor="right" id="Cargo" order="6" weight="0.32930514" />
<window_info anchor="right" id="Palette&#9;" order="7" />
<window_info anchor="right" id="Database" order="8" />
<window_info anchor="right" id="Maven Projects" order="9" />
<window_info anchor="right" id="Tracking Log Stats" order="10" weight="0.32930514" />
<window_info anchor="right" id="Maven" order="11" />
</layout>
<layout-to-restore>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.25226587" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Capture Tool" order="5" />
<window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.328594" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49848944" weight="0.3270142" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Terminal" order="8" sideWeight="0.49924472" weight="0.328594" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50151056" side_tool="true" weight="0.3271605" />
<window_info anchor="bottom" id="Version Control" order="10" />
<window_info anchor="bottom" id="Messages" order="11" weight="0.328594" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Capture Analysis" order="4" />
<window_info anchor="right" id="Theme Preview" order="5" />
<window_info anchor="right" id="Cargo" order="6" weight="0.32930514" />
<window_info anchor="right" id="Palette&#9;" order="7" />
<window_info anchor="right" id="Database" order="8" />
<window_info anchor="right" id="Maven Projects" order="9" />
<window_info anchor="right" id="Tracking Log Stats" order="10" weight="0.32930514" />
</layout-to-restore>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="COLUMN_ORDER" />
</State>
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="New project structure" />
<MESSAGE value="Update" />
@ -446,367 +356,8 @@
<MESSAGE value="Refactored" />
<MESSAGE value="progress" />
<MESSAGE value="Refactoring, MYSQL connection&#10;&#10;Refactored several files, split sites to site_index, site_poll_get and site_poll_post&#10;&#10;Added mysql connection to get code informations" />
<option name="LAST_COMMIT_MESSAGE" value="Refactoring, MYSQL connection&#10;&#10;Refactored several files, split sites to site_index, site_poll_get and site_poll_post&#10;&#10;Added mysql connection to get code informations" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/webserver/lib/delivery.rs" />
<entry file="file://$PROJECT_DIR$/data/polls/poll-1-old/pollinfo">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" column="22" selection-start-line="5" selection-start-column="22" selection-end-line="5" selection-end-column="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/utils/utils.rs" />
<entry file="file://$PROJECT_DIR$/data/polls/poll-1-old/questionblocks/block-1/blockinfo">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15">
<caret line="1" column="41" selection-start-line="1" selection-start-column="41" selection-end-line="1" selection-end-column="41" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/polls/poll-1-old/questionblocks/block-1/question-1.html">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="13" selection-start-column="13" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/utils/filesystem.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="221">
<caret line="13" column="1" lean-forward="true" selection-start-line="13" selection-start-column="1" selection-end-line="13" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/polls/poll-1-old/questionblocks/block-1/block-1.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="1" column="16" selection-start-line="1" selection-start-column="16" selection-end-line="1" selection-end-column="16" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-0/block.html" />
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-0/q1" />
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-0/q1.html" />
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.4.0/src/response/status.rs" />
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-0/q2.html" />
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-0.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="478">
<caret line="35" column="28" lean-forward="true" selection-start-line="35" selection-start-column="28" selection-end-line="35" selection-end-column="28" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-1.html">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/utils/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="1" column="8" selection-start-line="1" selection-start-column="8" selection-end-line="1" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/style/dashboard.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-647">
<caret line="1" column="30" selection-start-line="1" selection-start-column="30" selection-end-line="1" selection-end-column="30" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/formdata.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="20" column="31" selection-start-line="20" selection-start-column="31" selection-end-line="20" selection-end-column="31" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/filecache/cached_file.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="363">
<caret line="35" column="89" selection-start-line="35" selection-start-column="89" selection-end-line="35" selection-end-column="89" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-5.html" />
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/cache/questionblock-2.html" />
<entry file="file://$PROJECT_DIR$/style/global.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="12" column="1" selection-start-line="12" selection-start-column="1" selection-end-line="12" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/filecache/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="20" lean-forward="true" selection-start-line="2" selection-start-column="20" selection-end-line="2" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/filecache/cache.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="19" column="75" selection-start-line="19" selection-start-column="75" selection-end-line="19" selection-end-column="75" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/images.rs" />
<entry file="file://$PROJECT_DIR$/style/poll.js">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="21" selection-start-column="21" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/styles.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="20" column="52" selection-start-line="20" selection-start-column="52" selection-end-line="20" selection-end-column="52" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/style/poll.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="86">
<caret line="24" column="7" selection-start-line="24" selection-start-column="7" selection-end-line="24" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/utils/poll_generator.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="493">
<caret line="29" column="50" selection-start-line="29" selection-start-column="50" selection-end-line="29" selection-end-column="50" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/result.csv">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="249">
<caret line="42" column="15" selection-start-line="42" selection-start-column="15" selection-end-line="42" selection-end-column="15" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Cargo.lock" />
<entry file="file://$PROJECT_DIR$/src/database/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="20" column="21" lean-forward="true" selection-start-line="20" selection-start-column="21" selection-end-line="20" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/polls/poll-1/poll.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="615">
<caret line="41" column="7" lean-forward="true" selection-start-line="41" selection-start-column="7" selection-end-line="41" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" column="18" lean-forward="true" selection-start-line="9" selection-start-column="18" selection-end-line="10" selection-end-column="12" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/database-planning.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" column="5" selection-start-line="5" selection-start-column="5" selection-end-line="5" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/sites.rs" />
<entry file="file://$PROJECT_DIR$/src/webserver/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="7" column="14" selection-start-line="7" selection-start-column="14" selection-end-line="7" selection-end-column="14" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/site_poll_post.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375">
<caret line="25" column="37" selection-start-line="25" selection-start-column="37" selection-end-line="25" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/filecache/cache_error.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="360">
<caret line="24" column="24" selection-start-line="24" selection-start-column="24" selection-end-line="24" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Rocket.toml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="12" selection-start-line="15" selection-start-column="11" selection-end-line="15" selection-end-column="12" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Cargo.toml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" column="16" selection-start-line="2" selection-start-column="16" selection-end-line="2" selection-end-column="16" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="153">
<caret line="9" column="35" selection-start-line="9" selection-start-column="35" selection-end-line="9" selection-end-column="35" />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LICENSE">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/session_manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="29" selection-start-line="29" selection-end-line="29" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/database/code_management.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="1" column="30" selection-start-line="1" selection-start-column="30" selection-end-line="1" selection-end-column="30" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/database/database.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="467">
<caret line="53" column="1" selection-start-line="53" selection-start-column="1" selection-end-line="53" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/site_poll_get.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="986">
<caret line="58" column="29" selection-start-line="58" selection-start-column="29" selection-end-line="58" selection-end-column="29" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/favicon/favicon.ico">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/favicon.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="51">
<caret line="3" column="1" lean-forward="true" selection-start-line="3" selection-start-column="1" selection-end-line="3" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/site_index.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="78">
<caret line="17" column="28" selection-start-line="17" selection-start-column="28" selection-end-line="17" selection-end-column="28" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/templates.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="19" column="67" lean-forward="true" selection-start-line="19" selection-start-column="67" selection-end-line="19" selection-end-column="67" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/webserver/delivery.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="452">
<caret line="35" column="59" selection-start-line="35" selection-start-column="59" selection-end-line="35" selection-end-column="59" />
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
<MESSAGE value="Added favicon support and default favicon" />
<MESSAGE value="Bugfix: Added missing script closing tag (&lt;/script&gt;), smaller changes." />
<option name="LAST_COMMIT_MESSAGE" value="Bugfix: Added missing script closing tag (&lt;/script&gt;), smaller changes." />
</component>
</project>

8
Cargo.toml

@ -4,10 +4,10 @@ version = "0.1.5"
authors = ["anghenfil <ares@anghenfil.de>"]
[dependencies]
rocket = "0.4.0"
rocket_contrib = "0.4.0"
rocket = "0.4.1"
rocket_contrib = "0.4.1"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
lazy_static = "1.2.0"
lazy_static = "1.3.0"
rand = "0.6.5"
mysql = "*"
mongodb = "0.3.12"

14
README.md

@ -3,7 +3,7 @@
Simple, lightweight online poll tool written in rust, using Rocket webserver framework.
## Development status
DigiPoll is currently in alpha state. Nothing is stable and only a base functionality is implemented.
Surveyz is currently in alpha state. Nothing is stable and only a base functionality is implemented. Surveyz uses CouchDB as data storage.
Next steps:
* A lot of Refactoring (Clean-up)
@ -16,15 +16,3 @@ Next steps:
1. Create a new directory inside "polls"
2. Create a file inside your directory called "poll.json" (See example)
## Setting up MySQL Databse:
```rust
DROP TABLE IF EXISTS `T_codes`;
CREATE TABLE `T_codes` (
`p_code` varchar(10) NOT NULL,
`survey` varchar(10) DEFAULT NULL,
`is_valid` tinyint(1) DEFAULT NULL,
`stype` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`p_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```

54
src/database/database.rs

@ -1,54 +0,0 @@
use mysql as my;
#[derive(Debug, PartialEq, Eq)]
enum CodeTypes{
GROUPCODE,
SINGLECODE,
UNKNOWN
}
#[derive(Debug, PartialEq, Eq)]
struct CodeInfo{
code : String,
survey : String,
stype : CodeTypes,
valid : bool
}
fn check_code(code : String) -> Option<CodeInfo> {
let pool = my::Pool::new("mysql://test:localtest@localhost:3307/surveyz").unwrap();
let mut codeinfo: Vec<CodeInfo> = pool.prep_exec("SELECT p_code, survey, stype, is_valid from T_codes WHERE p_code = :code LIMIT 1", vec!(code)).map(|result| {
result.map(|x| x.unwrap()).map(|row| {
// ⚠️ Note that from_row will panic if you don't follow your schema
let (p_code, survey, stype, is_valid) : (String, String, i8, i8)= my::from_row(row);
CodeInfo {
code: p_code,
survey : survey,
stype: {
if stype == 1 {
CodeTypes::GROUPCODE
}else if stype == 2{
CodeTypes::SINGLECODE
}else{
CodeTypes::UNKNOWN
}
},
valid: {
if is_valid == 1 {
true
}else{
false
}
}
}
}).collect()
}).unwrap();
if codeinfo.len() == 1{
Some(codeinfo.remove(0))
}else{
None
}
}

2
src/database/mod.rs

@ -1,5 +1,5 @@
pub mod database;
pub mod code_management;
pub mod tests;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]

4
src/database/tests.rs

@ -0,0 +1,4 @@
#[cfg(test)]
mod tests{
}

74
src/db_system/document.rs

@ -0,0 +1,74 @@
//Data structures for serialisation
use std::string::ToString;
use std::collections::HashMap;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum DbType {
String(String),
I8(i8),
I16(i16),
I32(i32),
I64(i64),
I128(i128),
Bool(bool),
Char(char),
Document(Document)
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Field{
val: DbType
}
impl Field{
pub fn new(val_temp : DbType) -> Field{
Field{
val: val_temp
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Document{
fields : HashMap<String, Field>
}
impl Document{
pub fn new() -> Document{
Document{
fields: HashMap::new()
}
}
pub fn get(&self, key : &str) -> Option<&Field>{
self.fields.get(key)
}
pub fn insert(&mut self, key : String, value : Field){
self.fields.insert(key, value);
}
}
#[test]
fn test_document(){
let mut doc = Document::new();
doc.insert(String::from("test1"), Field::new(DbType::String(String::from("Test"))));
let testfield2 : Field = Field{
val: DbType::I32(120)
};
doc.fields.insert(String::from("test2"), testfield2);
match doc.get("test1").unwrap().val.clone(){
DbType::String(value) => println!("value:{}", value),
_ => {}
}
match doc.get("test2").unwrap().val.clone(){
DbType::I32(value) => println!("value:{}", value),
_ => {}
}
}

2
src/db_system/mod.rs

@ -0,0 +1,2 @@
pub mod document; //data storage to save data
mod storage;

70
src/db_system/storage.rs

@ -0,0 +1,70 @@
use db_system::document::{Document, Field, DbType};
use std::sync::RwLock;
use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use serde_json::{to_writer};
use std::fs::File;
use std::path::Path;
use std::io::BufWriter;
lazy_static! {
pub static ref DOCUMENTS: RwLock<DocumentStorage> = RwLock::new(DocumentStorage{
documents: HashMap::new()
});
}
#[derive(Serialize, Deserialize, Debug)]
pub struct DocumentStorage{
pub documents : HashMap<String, Document>
}
impl DocumentStorage{
pub fn new() -> DocumentStorage{
DocumentStorage{
documents: HashMap::new()
}
}
pub fn get(&self, id : &str) -> Option<&Document>{
match self.documents.get(id) {
Some(document) => Some(document),
_ => None
}
}
pub fn add(&mut self, id : String, document : Document){
self.documents.insert(id, document);
}
pub fn remove(&mut self, id : &str){
self.documents.remove(id);
}
pub fn load(){
}
pub fn save(&self) {
let mut output = File::create(Path::new("testsave.json"));
match output{
Ok(file)
=> {
serde_json::to_writer(BufWriter::new(file), &self.documents);
}
Err(_) => {}//TODO: CRITICAL WARNING, FALLBACK SAVE?
}
}
}
#[test]
pub fn testsave(){
let mut testdoc1 = Document::new();
testdoc1.insert(String::from("Test1"), Field::new(DbType::String(String::from("Test1 passt"))));
testdoc1.insert(String::from("Test2"), Field::new(DbType::String(String::from("Test2 passt"))));
let mut testdoc2 = Document::new();
testdoc2.insert(String::from("Test3"), Field::new(DbType::String(String::from("Test3 passt"))));
testdoc2.insert(String::from("Test4"), Field::new(DbType::String(String::from("Test4 passt"))));
DOCUMENTS.write().unwrap().add(String::from("testdoc1"), testdoc1);
DOCUMENTS.write().unwrap().add(String::from("testdoc2"), testdoc2);
DOCUMENTS.read().unwrap().save();
}

5
src/main.rs

@ -8,13 +8,12 @@ extern crate rocket_contrib;
extern crate serde_json;
extern crate serde;
extern crate rand;
#[macro_use]
extern crate mysql;
extern crate mongodb;
mod webserver;
mod filecache;
mod database;
mod utils;
mod db_system;
const VERSION: &'static str = env!("CARGO_PKG_VERSION");

Loading…
Cancel
Save