Skip to content

CargoHub #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 81 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
10a87de
Update van controllers
linkverk Jan 5, 2025
5dd1726
Update Filtering Feature
linkverk Jan 5, 2025
864f95a
Update met verminderen van search data
linkverk Jan 7, 2025
84491c1
Update tests en Suppliers
linkverk Jan 7, 2025
feda5ba
Update ClientsController.cs
linkverk Jan 8, 2025
ac9c5d7
Fix problems met tests
linkverk Jan 8, 2025
1eef792
ModelMapping Unittests
safouuwa Jan 9, 2025
9d9e2ef
Updated restrictions
linkverk Jan 10, 2025
01d4008
vernieuwde test job
safouuwa Jan 10, 2025
4f2ab5f
Aanpassing reportgenerator
safouuwa Jan 10, 2025
4aa06c4
Fresh copy install reportgenerator
safouuwa Jan 10, 2025
b62db85
Check for reportgenerator installation
safouuwa Jan 10, 2025
9aa09f2
Removed coverage percentage calculator
safouuwa Jan 10, 2025
5abb1c2
Remove unittest coverage report
safouuwa Jan 10, 2025
59110ce
Resterende deel vann coverage voor unittests verwijderd
safouuwa Jan 10, 2025
9b61dc1
Proef versie pagination
linkverk Jan 10, 2025
393d546
added xunit in csproj
safouuwa Jan 11, 2025
dc7070e
ItemID&Reference Restriction + Tests
safouuwa Jan 11, 2025
00d32a0
Item Transfer History
safouuwa Jan 11, 2025
b2d36c5
Updated tests
linkverk Jan 11, 2025
1855a40
Merge branch 'Development' into Filtering_Feature_1.1_fix
linkverk Jan 12, 2025
3c567e6
Update pagination
linkverk Jan 12, 2025
9d82abd
Update controllers met get all
linkverk Jan 13, 2025
4084b78
.Gitignore update to not include .logs
safouuwa Jan 13, 2025
c6c243c
Initial RequestLog Revamp
safouuwa Jan 13, 2025
d5f5ed7
RequestLog Filtering Update
safouuwa Jan 13, 2025
82788ef
Swagger Fix
safouuwa Jan 13, 2025
a52ee13
Update Controllers en tests
linkverk Jan 13, 2025
0781d7f
Update tests na de PR review
linkverk Jan 13, 2025
6be6135
Nieuwe RequestLog Tests
safouuwa Jan 13, 2025
3c83eb2
Overbodige id verwijderd
linkverk Jan 13, 2025
c99a4a5
Example test
linkverk Jan 13, 2025
8e16725
Datetime aangepast
safouuwa Jan 13, 2025
8fcaa3d
Test Caching time
Sin0fGREED Jan 13, 2025
b57bb8d
Update dotnet.yml
Sin0fGREED Jan 13, 2025
d21225f
Update dotnet.yml
Sin0fGREED Jan 13, 2025
7f6f43e
Update dotnet.yml
Sin0fGREED Jan 13, 2025
6f65918
moved caching to after setup
Sin0fGREED Jan 13, 2025
e254283
move setup python one step earlier in indentation
Sin0fGREED Jan 13, 2025
9e2bdc1
reverted back to old working commit and added Caching of coverage report
Sin0fGREED Jan 13, 2025
9bdb1c2
update branch name
Sin0fGREED Jan 13, 2025
296405e
Update a test pagination
linkverk Jan 14, 2025
ef2e14a
New Source_ID Update
safouuwa Jan 14, 2025
8ff8e29
Emptied out Requestlog
safouuwa Jan 14, 2025
6944ced
Fix errors
linkverk Jan 14, 2025
89f0ca0
FIx in test_operative.py error
linkverk Jan 14, 2025
c7acb86
Merge pull request #37 from safouuwa/RequestLogRevamp
linkverk Jan 14, 2025
7a8b1c9
Merge branch 'Development' of https://github.com/safouuwa/Software-Co…
safouuwa Jan 14, 2025
5b06d37
Merge pull request #33 from safouuwa/Filtering_Feature_1.1_fix
safouuwa Jan 14, 2025
0908bab
Merge pull request #38 from safouuwa/TestCaching
safouuwa Jan 14, 2025
eba00c4
Delete RequestLogs.txt
Sin0fGREED Jan 14, 2025
11704af
Merge pull request #36 from safouuwa/ItemID&ItemReference-Restriction
Sin0fGREED Jan 14, 2025
7e71085
Merge branch 'Development' of https://github.com/safouuwa/Software-Co…
safouuwa Jan 14, 2025
f36aa02
Merge pull request #39 from safouuwa/Pagination
safouuwa Jan 14, 2025
742ea15
RequestLog Tests geoptimaliseerd
safouuwa Jan 14, 2025
65de0bd
endpoint to view some details
linkverk Jan 15, 2025
653a0d8
Fix problems met tests en request codes
linkverk Jan 16, 2025
87111bc
Merge branch 'Development' into Unittests-ModelMapping
linkverk Jan 16, 2025
a11b8a1
Merge pull request #35 from safouuwa/Unittests-ModelMapping
linkverk Jan 16, 2025
1d370bb
Fix na review PR
linkverk Jan 16, 2025
5ac6659
Merge pull request #40 from safouuwa/Endpoints-to-view
safouuwa Jan 16, 2025
282de57
added sorting by Id
Sin0fGREED Jan 16, 2025
58c3f10
Added a couple tests for Sort by
Sin0fGREED Jan 16, 2025
35cd36e
Updated Deployment Diagram
safouuwa Jan 17, 2025
16aef11
added the last set of tests for get endpoint sort by asc/desc
Sin0fGREED Jan 17, 2025
3d069e4
Updaten van tijd opnemen
linkverk Jan 17, 2025
10691c4
Merge branch 'Development' into Sort-by-descending/ascending-for-get-…
Sin0fGREED Jan 17, 2025
d845215
Merge pull request #43 from safouuwa/Sort-by-descending/ascending-for…
linkverk Jan 17, 2025
d487670
Merge pull request #42 from safouuwa/Release-Job-Aanpassen
Sin0fGREED Jan 17, 2025
553693a
URL V1 -> V2
safouuwa Jan 18, 2025
dc2a3bc
Namespace Update
safouuwa Jan 18, 2025
76eaccf
V1 + V2
safouuwa Jan 18, 2025
f264b06
Changed pytest to only run V2
safouuwa Jan 18, 2025
47b57fa
Revert to base after tests
safouuwa Jan 18, 2025
0f5a166
Alternate way to Test only V2
safouuwa Jan 18, 2025
df07b39
Run V1 tests in workflow
safouuwa Jan 18, 2025
4a8c8e2
Remove coverage from V1 tests run
safouuwa Jan 18, 2025
e6b565f
revert json change
safouuwa Jan 20, 2025
1ec90dd
floor_manager test change
safouuwa Jan 20, 2025
7a89709
test_warehouse change
safouuwa Jan 20, 2025
60e7810
Revert location delete
safouuwa Jan 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ jobs:
run: |
dotnet build --no-restore
echo "time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT

test:
needs: build
runs-on: self-hosted
outputs:
TEST_TIME: ${{ steps.test-time.outputs.time }}
COVERAGE: ${{ steps.coverage.outputs.percentage }}
UNIT_TEST_COVERAGE: ${{ steps.unit-test-coverage.outputs.percentage }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
Expand All @@ -61,6 +63,8 @@ jobs:
${{ runner.os }}-dotnet-
- name: Build the application
run: dotnet build --configuration Release
- name: Run unit tests with coverage
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --results-directory ./coverage --verbosity normal
- name: Run application
run: dotnet run --no-build --configuration Release --urls=${{ secrets.LOCALHOST }} & sleep 5
- name: Setup Python
Expand All @@ -78,8 +82,10 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install httpx pytest coverage
- name: Run integration tests
run: coverage run -m pytest
- name: Run integration tests V1
run: pytest "C#apiV1/Tests"
- name: Run integration tests V2
run: coverage run -m pytest "C#api/Tests"
- name: Generate code coverage report
id: coverage
run: |
Expand Down Expand Up @@ -132,11 +138,18 @@ jobs:
coverage-summary.txt
parsed-coverage-summary.txt
coverage.xml
coveragereport/**
retention-days: 1
- name: Cache Coverage Reports
uses: actions/cache@v3
with:
path: coverage/
key: ${{ runner.os }}-coverage-${{ github.run_id }}
- name: Set test Completion time
id: test-time
run: |
echo "time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT

release:
runs-on: self-hosted
if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main'
Expand All @@ -155,19 +168,19 @@ jobs:
- name: Generate release notes
run: |
git fetch --all --tags
# Get the date 4 weeks ago in ISO 8601 format
FOUR_WEEKS_AGO=$(date -d '4 weeks ago' '+%Y-%m-%d' || date -v '-4w' '+%Y-%m-%d')
echo "Debug: Date 4 weeks ago is $FOUR_WEEKS_AGO"
# Get the date 2 weeks ago in ISO 8601 format
TWO_WEEKS_AGO=$(date -d '2 weeks ago' '+%Y-%m-%d' || date -v '-2w' '+%Y-%m-%d')
echo "Debug: Date 2 weeks ago is $TWO_WEEKS_AGO"
echo "# Release Notes" > release_notes.md
echo "## Branches merged into Development in the last 4 weeks:" >> release_notes.md
# Get merged branches in the last 4 weeks
MERGED_BRANCHES=$(git log --since="$FOUR_WEEKS_AGO" --merges --pretty=format:"%s%n%b" origin/Development |
echo "## Branches merged into Development in the last 2 weeks:" >> release_notes.md
# Get merged branches in the last 2 weeks
MERGED_BRANCHES=$(git log --since="$TWO_WEEKS_AGO" --merges --pretty=format:"%s%n%b" origin/Development |
grep -E "Merge (branch|pull request)|into 'Development'" |
sed -E "s/Merge (branch|pull request) //g; s/ into Development//g; s/from //g; s/'//g; s/\"//g" |
sort -u)
echo "Merged branches: $MERGED_BRANCHES"
if [ -z "$MERGED_BRANCHES" ]; then
echo "No branches merged in the last 4 weeks." >> release_notes.md
echo "No branches merged in the last 2 weeks." >> release_notes.md
else
echo "$MERGED_BRANCHES" | sed 's/^/- /' >> release_notes.md
fi
Expand Down Expand Up @@ -258,6 +271,7 @@ jobs:

Branch: ${{ github.ref_name }}
Event: ${{ github.event_name }}

close_pr_on_failure:
needs: [build, test]
runs-on: ubuntu-latest
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ cover/
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
Expand Down Expand Up @@ -184,8 +183,6 @@ obj/
packages/
*.snupkg

# Logs
*.log

# IDE specific files
.idea/
Expand Down
5 changes: 5 additions & 0 deletions C#api/Attributes/LogRequestAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace AttributesV2;
[AttributeUsage(AttributeTargets.Method)]
public class LogRequestAttribute : Attribute
{
}
5 changes: 3 additions & 2 deletions C#api/Controllers/BaseApiController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Mvc;
using Providers;
using ProvidersV2;
using ProcessorsV2;

[ApiController]
[Route("api/v1/[controller]")]
[Route("api/v2/[controller]")]
public abstract class BaseApiController : ControllerBase
{
protected readonly NotificationSystem _notificationSystem;
Expand Down
56 changes: 32 additions & 24 deletions C#api/Controllers/ClientsController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Microsoft.AspNetCore.Mvc;
using Models;
using ModelsV2;
using Microsoft.AspNetCore.JsonPatch;

using Providers;
using HelpersV2;
using ProcessorsV2;
using ProvidersV2;
using System.Text.Json;
using System.Xml.XPath;

[ApiController]
[Route("api/v1/[controller]")]
[Route("api/v2/[controller]")]
public class ClientsController : BaseApiController
{
public ClientsController(
Expand All @@ -16,46 +18,53 @@
}

[HttpGet]
public IActionResult GetClients()
public IActionResult GetClients(
[FromQuery] int page = 1,
[FromQuery] int pageSize = 10,
[FromQuery] string sortOrder = "asc"
)
{
var auth = CheckAuthorization(Request.Headers["API_KEY"], "clients", "get");
if (auth != null) return auth;

var clients = DataProvider.fetch_client_pool().GetClients();
return Ok(clients);
clients = sortOrder.ToLower() == "desc"
? clients.OrderByDescending(c => c.Id).ToList()
: clients.OrderBy(c => c.Id).ToList();
var response = PaginationHelper.Paginate(clients, page, pageSize);
return Ok(response);
}

[HttpGet("search")]
public IActionResult SearchClients(
[FromQuery] int? id = null,
[FromQuery] string name = null,

Check warning on line 39 in C#api/Controllers/ClientsController.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.
[FromQuery] string address = null,

Check warning on line 40 in C#api/Controllers/ClientsController.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.
[FromQuery] string city = null,
[FromQuery] string zipCode = null,
[FromQuery] string province = null,
[FromQuery] string country = null,

Check warning on line 41 in C#api/Controllers/ClientsController.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.
[FromQuery] string contactName = null,

Check warning on line 42 in C#api/Controllers/ClientsController.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.
[FromQuery] string contactPhone = null,
[FromQuery] string contactEmail = null)
[FromQuery] int page = 1,
[FromQuery] int pageSize = 10

)
{
var auth = CheckAuthorization(Request.Headers["API_KEY"], "clients", "get");
if (auth != null) return auth;

try
{
var clients = DataProvider.fetch_client_pool().SearchClients(id,name, address, city, zipCode, province, country, contactName, contactPhone, contactEmail);

if (clients == null || !clients.Any())
var clients = DataProvider.fetch_client_pool().SearchClients(name, address, country, contactName);


if (clients == null || !clients.Any())
{
return BadRequest("Error, er is geen Client(s) gevonden met deze gegevens.");
}
var response = PaginationHelper.Paginate(clients, page, pageSize);
return Ok(response);
}
catch (ArgumentException ex)
{
return BadRequest("Error, er is geen Client(s) gevonden met deze gegevens.");
return BadRequest(ex.Message);
}
return Ok(clients);
}
catch (ArgumentException ex)
{
return BadRequest(ex.Message);
}
}

[HttpGet("{id}")]
public IActionResult GetClient(int id)
Expand Down Expand Up @@ -202,4 +211,3 @@
return Ok();
}
}

32 changes: 21 additions & 11 deletions C#api/Controllers/InventoriesController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using Models;
using Providers;
using ModelsV2;
using ProvidersV2;
using System.Text.Json;
using HelpersV2;
using ProcessorsV2;


[ApiController]
[Route("api/v1/[controller]")]
[Route("api/v2/[controller]")]
public class InventoriesController : BaseApiController
{
public InventoriesController(
Expand All @@ -15,22 +17,30 @@ public InventoriesController(
}

[HttpGet]
public IActionResult GetInventories()
public IActionResult GetInventories(
[FromQuery] int page = 1,
[FromQuery] int pageSize = 10,
[FromQuery] string sortOrder = "asc"
)
{
var auth = CheckAuthorization(Request.Headers["API_KEY"], "inventories", "get");
if (auth is UnauthorizedResult) return auth;

var inventories = DataProvider.fetch_inventory_pool().GetInventories();

if (auth is OkResult)
inventories = sortOrder.ToLower() == "desc"
? inventories.OrderByDescending(i => i.Id).ToList()
: inventories.OrderBy(i => i.Id).ToList();
if (auth is OkResult)
{
var user = AuthProvider.GetUser(Request.Headers["API_KEY"]);
var locations = DataProvider.fetch_location_pool().GetLocations();
var locationids = locations.Where(x => user.OwnWarehouses.Contains(x.Warehouse_Id)).Select(x => x.Id).ToList();
inventories = inventories.Where(x => x.Locations.Any(y => locationids.Contains(y))).ToList();
}

return Ok(inventories);
var response = PaginationHelper.Paginate(inventories, page, pageSize);

return Ok(response);
}

[HttpGet("{id}")]
Expand All @@ -52,7 +62,7 @@ public IActionResult CreateInventory([FromBody] Inventory inventory)
if (auth != null) return auth;
if (inventory.Id != null) return BadRequest("Inventory: Id should not be given a value in the body; Id will be assigned automatically.");
var success = DataProvider.fetch_inventory_pool().AddInventory(inventory);
if (!success) return BadRequest("Inventory: Id already exists");
if (!success) return BadRequest("Item ID and Reference do not refer to the same Item entity");

DataProvider.fetch_inventory_pool().Save();
return CreatedAtAction(nameof(GetInventory), new { id = inventory.Id }, inventory);
Expand All @@ -65,9 +75,9 @@ public IActionResult UpdateInventory(int id, [FromBody] Inventory inventory)
if (auth != null) return auth;

if (inventory.Id != null) return BadRequest("Inventory: Id should not be given a value in the body; Id will be assigned automatically.");

if (DataProvider.fetch_inventory_pool().GetInventory(id) == null) return NoContent();
var success = DataProvider.fetch_inventory_pool().UpdateInventory(id, inventory);
if (!success) return NoContent();
if (!success) return BadRequest("Item ID and Reference do not refer to the same Item entity");

DataProvider.fetch_inventory_pool().Save();
return Ok();
Expand Down Expand Up @@ -145,7 +155,7 @@ public IActionResult PartiallyUpdateInventory(int id, [FromBody] JsonElement par

var success = InventoryPool.ReplaceInventory(id, existingInventory);
if (!success)
return StatusCode(500, "Failed to update inventory");
return BadRequest("Item ID and Reference do not refer to the same Item entity");

DataProvider.fetch_inventory_pool().Save();
return Ok(existingInventory);
Expand Down
17 changes: 12 additions & 5 deletions C#api/Controllers/Item_GroupsController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Models;
using ModelsV2;
using System.Text.Json;
using Providers;
using ProvidersV2;
using HelpersV2;
using ProcessorsV2;

[ApiController]
[Route("api/v1/[controller]")]
[Route("api/v2/[controller]")]
public class Item_GroupsController : BaseApiController
{
public Item_GroupsController(
Expand All @@ -14,13 +16,18 @@ public Item_GroupsController(
}

[HttpGet]
public IActionResult GetItemGroups()
public IActionResult GetItemGroups(
[FromQuery] int page = 1,
[FromQuery] int pageSize = 10)
{
var auth = CheckAuthorization(Request.Headers["API_KEY"], "item_groups", "get");
if (auth != null) return auth;

var itemGroups = DataProvider.fetch_itemgroup_pool().GetItemGroups();
return Ok(itemGroups);

var response = PaginationHelper.Paginate(itemGroups, page, pageSize);

return Ok(response);
}

[HttpGet("{id}")]
Expand Down
17 changes: 12 additions & 5 deletions C#api/Controllers/Item_LinesController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Text.Json;
using Microsoft.AspNetCore.Mvc;
using Models;
using Providers;
using ModelsV2;
using ProvidersV2;
using HelpersV2;
using ProcessorsV2;

[ApiController]
[Route("api/v1/[controller]")]
[Route("api/v2/[controller]")]
public class Item_LinesController : BaseApiController
{
public Item_LinesController(
Expand All @@ -14,13 +16,18 @@ public Item_LinesController(
}

[HttpGet]
public IActionResult GetItemLines()
public IActionResult GetItemLines(
[FromQuery] int page = 1,
[FromQuery] int pageSize = 10)
{
var auth = CheckAuthorization(Request.Headers["API_KEY"], "item_lines", "get");
if (auth != null) return auth;

var itemLines = DataProvider.fetch_itemline_pool().GetItemLines();
return Ok(itemLines);

var response = PaginationHelper.Paginate(itemLines, page, pageSize);

return Ok(response);
}

[HttpGet("{id}")]
Expand Down
Loading
Loading